# Haproxy 2.2 ( CORS proper Implementation)

**URL:** <https://discourse.haproxy.org/t/haproxy-2-2-cors-proper-implementation/6678>\
**Category:** Help!\
**Created:** [June 25, 2021, 9:06am UTC](https://discourse.haproxy.org/t/haproxy-2-2-cors-proper-implementation/6678 "2021-06-25T09:06:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anupam\_4881](https://avatars.discourse-cdn.com/v4/letter/a/59ef9b/32.png) [@Anupam\_4881](https://discourse.haproxy.org/u/Anupam_4881)\
**Post date:** [June 25, 2021, 9:06am UTC](https://discourse.haproxy.org/t/haproxy-2-2-cors-proper-implementation/6678/1 "2021-06-25T09:06:11Z")

</div>

Hi Team,

We are trying to use standard implementation of CORS ( cross origin shared resources ) with HAProxy 2.2 , after implementation we observed that this is working but we will have to enter all subdomain and domain manually. We want to allow wild card expression so that manual subdomain entries need not to enter every time for same domain.

haproxy -v  
2.2.10  
lua version : 5.3.4  
copy below file and add in haprox.conf

> <https://github.com/haproxytech/haproxy-lua-cors/blob/master/example/haproxy/cors.lua>

Will appreciate your expert help to achieve this.

To achieve wild card support I tried below option but nothing work , kindly suggest right way.  
http-request lua.cors “\*”, " _.example.com", "_" --not work

http-request lua.cors “_", " ._.example.com”, “\*” --not work

----------------------Sample added lines in Configuration files and working with subdomain entries -----------------------

global  
lua-load /etc/haproxy/cors.lua

frontend https\_frontend  
http-request capture req.hdr(Origin) len 40  
http-request lua.cors “_", “[help.example.com](http://help.example.com),[admin.example.com](http://admin.example.com),[hire.example.com](http://hire.example.com)”, "_”

backend dashboard  
http-response lua.cors

Regards  
Anupam
