I want to enable HTTP Strict Transport Security (HSTS) Headers globally for all my backends in HAProxy v1.5.
Following the instructions from https://www.haproxy.com/blog/haproxy-and-http-strict-transport-security-hsts-header-in-http-redirects/ I can add the following line to a backend configuration file and it works as expected.
http-response set-header Strict-Transport-Security max-age=16000000;\
includeSubDomains;\ preload;
I have a dozen backend files and will likely have more in the future. I'd like to set this in one place.
I'd like something similar to how it's set up globally in Apache's httpd.conf
:
Header always set Strict-Transport-Security "max-age=63072000; includeSubdomains;"
haproxy doesn't have hierarchical configuration like Apache does. I don't think this is possible.
Now HAPROXY does support HSTS for this i have followed below steps
Here is my cfg file
Step # 1 Add static cipher (NOT NECESSARY I AM DOING FOR GOOD WIL )
Step # 2 Create ACL to mark secure packets
Secure your Cookie
Finally apply HSTS settings
After that restart haproxy