my haproxy configuration is:
# Configuration for 678da17a-5c8f-4d2b-9431-f3019aae9726
log /dev/log local0 debug alert
log /dev/log local1 notice alert
stats socket /var/lib/neutron/lbaas/v2/678da17a-5c8f-4d2b-9431-f3019aae9726/haproxy_stats.sock mode 0666 level user
timeout connect 5000
timeout client 50000
timeout server 50000
server 9add0118-0255-4ee3-998a-875fb251624b 220.127.116.11:443 weight 1
I want to configure frontend using 5200 port to access backend server 18.104.22.168:443.
But when i request https://22.214.171.124:5200, the request change to https://126.96.36.199/index.html. It leads to request failure.
Why happens that?
HAProxy is requesting https://188.8.131.52/ from the backend. That's the root directory and not actually a file, so the backend responds by redirecting the browser to the default (index.html) file, which from the backend's perspective is at https://184.108.40.206/index.html. Confirm this by using developer tools in your browser and you'll likely see the 301 code.
There's (at least) two ways to handle that. First is on the backend web server - the backend knows nothing about port 5200 unless you configure it to. Second is in HAProxy by rewriting the
Location: header, e.g.
http-request replace-header Location ^https://220.127.116.11/(.*)$ https://18.104.22.168:5200/1
If you use the HAProxy approach, note that you would need to do it for IP addresses and domain names separately (if you will be accessing using both and want both to work).
Answered by tater on December 2, 2020
Get help from others!