Trying to rewrite the host header in HAProxy, but can't figure how to do it right.

I need the to rewite to another domain.

Users access the webpage on URI: site1.dev.example.com and I need to rewrite the host-header on the backend to site1.example.local

It should take all characters until the first dot, and then switch to the local domain.

I'm more of a Nginx user but I googled some documents, see if they helps.

It looks like you will need acl in HAProxy to help you out.

On how to implement acl , this article from the Enterprise Documentation should be helpful:

To update an X-Forwarded-For header to add the client IP at the top of the list:

acl h_xff_exists req.hdr(X-Forwarded-For) -m found
http-request replace-header X-Forwarded-For (.*) %[src],1 if h_xff_exists

The example above updates the string below:

X-Forwarded-For: 192.168.100.1, 10.0.0.2

to become the following one (considering the client IP is 172.16.0.2):

X-Forwarded-For: 172.16.0.2, 192.168.100.1, 10.0.0.2
  • I like how your answer basically states "if you don't know the answer, here is how to tackle the problem yourself" as the person asking the question didn't provide any prove of doing some research himself first. – Tom Oct 16 at 8:32

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.