I'm sort of new to ha-proxy and trying to rewrite the host_header, keeping the sub-domain intact and this is my first attempt to achieve that:
http-request set-var(req.get_sub) req.hdr(host),lower,regsub(\.website\.com$,) if { hdr_end(host) -i .website.com }
http-request set-header Host %[var(req.get_sub)].company.net if { var(req.get_sub) -m found }
.....
It's working, to some extent with one issue: it's rewriting the header to demo.company.net
just fine when the URL is like demo.website.com
. But it returns the original header, if the URL is just website.com
, instead of company.net
. I understand that it's probably doing the correct thing according to my config but cannot figure out how to make that conditional. Can anyone point me to the right direction pls?
Another thing I wanted to ask: If there is way to define a variable for website.com
and use that variable afterwards? Really appreciate any helps/pointer on that.
Best!
0 Answers