How to configure HAproxy to redirect multiple domain
24,981
As mentioned previously this is not really load balancing, but it's possible.
Try something like:
frontend http-in
bind *:80
# urls
acl host_foo hdr(host) -i www.foo.com
acl host_bar hdr(host) -i www.bar.com
acl host_zoo hdr(host) -i www.zoo.com
# clusters
use_backend foo_cluster if host_foo
use_backend bar_cluster if host_bar
use_backend zoo_cluster if host_zoo
backend foo_cluster
mode http
balance roundrobin
option forwardfor
server server1 ip_other_webserver:81 check
backend bar_cluster
mode http
balance roundrobin
option forwardfor
server server1 ip_other_webserver:82 check
backend zoo_cluster
mode http
balance roundrobin
option forwardfor
server server1 ip_other_webserver:8080 check
Related videos on Youtube
Author by
hellb0y77
Updated on November 27, 2022Comments
-
hellb0y77 over 1 year
i need configure HAproxy to redirect multiple domain with SSL, i need redirect in this way:
www.foo.com redirect to ip_other_webserver:81 www.bar.com redirect to ip_other_webserver:82 www.zoo.com redirect to ip_other_webserver:8080
I do not know HAproxy, in the past i did the same configuration with nginx but i also need the load balancer. I can not find a configuration example. Thanks
-
Admin over 9 yearsWhy don't you try with DNS?
-
Admin over 9 yearsBecause i need connect to other ports, not http/s ports, and need a load balancer
-
Admin over 9 yearsload balancing is when requesting a single domain you resolve (with some strategy) to one ip address from a pool; in this case you have three different domains with three service port, i don't see where the load balancing should happen
-