4

I have a HAProxy set up to redirect traffic to a few internal servers.

What I'm trying to do is to set some response headers, based on the request host. Unfortunately I can't get it to work.

Current settings look like this

acl mywebsite req.hdr(host) -i example.com

http-response set-header X-Frame-Options SAMEORIGIN if mywebsite
http-response set-header X-XSS-Protection 1;mode=block if mywebsite
http-response set-header X-Content-Type-Options nosniff if mywebsite

As I understood http-response set-header can't read the request header. Is there any way around this?

elmo
  • 55
  • 2
  • 8

1 Answers1

6

You can use set-var

   http-request set-var(txn.host) hdr(Host)
   acl myhost var(txn.host) -m str example.com
   http-response set-header X-Frame-Options SAMEORIGIN if myhost