Rewrite host address of backend server
-
Hi,
With HAProxy, I am trying to write a rule that changes the address like so:
https://abc-test.example.com to http://def-test.example.com
My frontend handles the https and I have an ACL that checks the URL starts with 'abc'. If so, it passes it to a backend:
backend test_ipvANY mode http id 126 log global errorfile 503 /var/etc/haproxy/errorfile_test_ipvANY_503_test timeout connect 30000 timeout server 30000 retries 3 acl sw_start var(txn.txnhost) -m sub -i abc- http-request set-var(txn.txnhost) hdr(host) http-request set-uri %[req.hdr(host),regsub(abc-,def-,g)] if sw_start server xyz-test.example.com 10.1.102.24:80 id 127 check inter 1000
Unfortunately, I get back the error:
File Not Found URI: def-test.example.com Method: GET Arguments: 0
Can anyone tell me where I am going wrong? I realise that my backend server address is not the same as the one set in http-request set-uri but then I can't add wildcards to the backend server so I just created a dummy. Am I going about this the right way?
Thanks
-
@jonathan-young you need a redirection rule - http-request redirect along with a conditional i think would help.
http-request redirect location def-test.example.com code 302 if { hdr(host) -i abc-test.example.com