I’m trying to enable CORS on HAPROXY using the the lua library but getting the below warnings when I start the HAPROXY service which looks as if my CORS config rules will be ignored
Apr 21 14:13:16 haproxyobvtest haproxy[3697]: [NOTICE] (3697) : path to executable is /usr/sbin/haproxy
Apr 21 14:13:16 haproxyobvtest haproxy[3697]: [WARNING] (3697) : config : parsing [/etc/haproxy/haproxy.cfg:27] : 'option httplog' not usable with frontend 'LoadBalancer' (needs>
Apr 21 14:13:16 haproxyobvtest haproxy[3697]: [WARNING] (3697) : config : 'http-request' rules ignored for frontend 'LoadBalancer' as they require HTTP mode.
Apr 21 14:13:16 haproxyobvtest haproxy[3697]: [WARNING] (3697) : config : 'http-response' rules ignored for frontend 'LoadBalancer' as they require HTTP mode.
Apr 21 14:13:16 haproxyobvtest haproxy[3697]: [NOTICE] (3697) : New worker (3699) forked
Apr 21 14:13:16 haproxyobvtest haproxy[3697]: [NOTICE] (3697) : Loading success.
Apr 21 14:13:16 haproxyobvtest systemd[1]: Started HAProxy Load Balancer.
Below is my haproxy.cfg
global
lua-load /etc/opt/rh/rh-haproxy18/haproxy/cors.lua
log /dev/log local0
log /dev/log local1 notice
chroot /var/lib/haproxy
stats socket /run/haproxy-admin.sock mode 660 level admin expose-fd listeners
stats timeout 30s
user haproxy
group haproxy
daemon
# Default SSL material locations
ca-base /etc/ssl/certs
crt-base /etc/ssl/private
# Default ciphers to use on SSL-enabled listening sockets.
# For more information, see ciphers(1SSL). This list is from:
# https://hynek.me/articles/hardening-your-web-servers-ssl-ciphers/
# An alternative list with additional directives can be obtained from
# https://mozilla.github.io/server-side-tls/ssl-config-generator/?server=haproxy
ssl-default-bind-ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:RSA+AESGCM:RSA+AES:!aNULL:!MD5:!DSS
ssl-default-bind-options no-sslv3
defaults
log global
mode http
option httplog
option dontlognull
timeout connect 5000
timeout client 50000
timeout server 50000
frontend LoadBalancer
bind *:443
mode http
default_backend backend_servers
http-request lua.cors "GET,PUT,POST,OPTIONS" "*" "*"
http-response lua.cors
backend backend_servers
mode http
balance roundrobin
option tcpka
option tcp-check
server 172.18.18.132 172.18.18.132:31811 check
server 172.18.18.133 172.18.18.133:31811 check
server 172.18.18.134 172.18.18.134:31811 check
server 172.18.18.135 172.18.18.135:31811 check
server 172.18.18.136 172.18.18.136:31811 check
server 172.18.18.137 172.18.18.137:31811 check
server 172.18.18.138 172.18.18.138:31811 check
server 172.18.18.139 172.18.18.139:31811 check
server 172.18.18.140 172.18.18.140:31811 check
server 172.18.18.141 172.18.18.141:31811 check
listen stats
bind :9000 # Listen on localhost:9000
mode http
stats enable # Enable stats page
stats hide-version # Hide HAProxy version
stats realm Haproxy\ Statistics # Title text for popup window
stats uri /haproxy_stats # Stats URI
My cors.lua file I just took from below gitrepo without editing