Reputation: 1590
I have 3 virtual hosts on a single IP address.Host_a, Host_b and Host_c all mapping to 192.168.1.10.
My HAProxy configuration is as follows:
frontend http
.
.
.
acl host_one path_end -i /ABC/application
acl host_two path_end -i /XYZ/application
acl host_three path_end -i /PQR/application
use_backend be_host1 if host_one
use_backend be_host2 if host_two
use_backend be_host3 if host_three
backend be_host1
server channel Host_a
backend be_host2
server channel Host_b
backend be_host3
server channel Host_c
Now for example, HAproxy forwards request to 192.168.1.10/ABC/application
in case it matches an incoming URL ending with /ABC/application
. Is there a way I could forward it to http://Host_a/ABC/application
instead ? It is important for me that they use the hostname instead of its corresponding IP address.
Upvotes: 0
Views: 3790
Reputation: 5012
The hostname is a part of the HTTP request, and that means you can use the HAProxy option reqirep
to set it to whatever you want.
reqirep ^Host: Host:\ Host_a
You can use this type of option in all three of your backends.
Upvotes: 1