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?

2
  • No idea, but what is "if example"? Did you mean "if mywebsite"? Apr 19, 2018 at 19:54
  • jep. didn't notice that :P
    – elmo
    Apr 20, 2018 at 7:43

1 Answer 1

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
1
  • can't vote you up because of low rep but thanks a lot! that solved it.
    – elmo
    Apr 20, 2018 at 9:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .