Hi,
Is there a HAProxy setting equivalent to apache's "ProxyPreserveHost" ?
I want to proxy the request from siteA to siteB , both sites have HAProxy
service configured:
siteA: sitea.sample.com
backend SFARM-PROXY1
server PROXY1 abc.sample.com:80
backend SFARM-PROXY2
server PROXY2 xyz.sample.com:80
acl PROXY1 path_reg ^/proxy1$|^/proxy1/
use_backend SFARM-PROXY1 if PROXY1
acl PROXY2 path_reg ^/proxy2$|^/proxy2/
use_backend SFARM-PROXY2 if PROXY2
siteB: siteb.sample.com (it has many CNAMEs created, including abc.sample.com,
xyz.sample.com, …etc)
acl ABC hdr_dom(host) -i abc.sample.com
use_backend SFARM-ABC if ABC
acl XYZ hdr_dom(host) -i xyz.sample.com
use_backend SFARM-XYZ if XYZ
acl …...
When I access http://sitea.sample.com/proxy1 , the browser throws 502 Gateway
Error and siteB haproxy.log shows 503 Service Not Available.
The reason is that Host header contains "sitea.sample.com" when it reaches
siteB and there is no acl matched.
I tried using rewrite rule on Host header in siteA config:
backend SFARM-PROXY1
reqirep ^Host: Host:\ abc.sample.com
server PROXY1 abc.sample.com:80
It didn't work because accessing http://sitea.sample.com/proxy1 returned
http://abc.sample.com/proxy1<http://sitea.sample.com/proxy1> in the browser.
We want browser to stay on sitea.sample.com and not change to abc.sample.com.
Please advise.
Thanks
Diana