HAProxy request rules execute in declaration order
An edge proxy often performs several jobs before it selects a backend: reject forbidden paths, normalize headers, apply rate limits, and choose a certificate or upstream. HAProxy's http-request rules are evaluated in declaration order. Rules inherited from defaults run before rules in the associated proxy. A security decision placed after a header mutation can therefore see different input than the administrator expected.
Order security before routing
A minimal policy should make the intended deny path visible and keep later rules from changing the decision.
frontend public_https bind :443 ssl crt /etc/haproxy/certs/ http-request deny if { path_beg /internal } http-request set-header X-Forwarded-Proto https default_backend application
Enter fullscreen mode
Exit fullscreen mode
The example is only a starting point.…