Last active
February 15, 2022 20:54
-
-
Save haproxytechblog/861381eb2979989393eebbd79d3ea240 to your computer and use it in GitHub Desktop.
Enabling CORS in HAProxy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
frontend www | |
bind :80 | |
# Add a response header | |
http-response add-header X-XSS-Protection "1; mode=block" | |
# Remove a response header | |
http-response del-header X-Powered-By | |
# Change a response header | |
http-response set-header Via "HTTP/2.0 haproxy1" | |
default_backend webservers |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ haproxy -vv | grep Lua | |
Built with Lua version: Lua 5.3.5 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
global | |
lua-load /etc/haproxy/cors.lua |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Origin: http://example.com |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
listen api | |
bind :80 | |
http-request lua.cors "GET,PUT,POST" "example.com" "*" | |
http-response lua.cors | |
server s1 192.168.50.20 check | |
server s2 192.168.50.21 check | |
server s3 192.168.50.22 check |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment