6

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

  • Why don't you try with DNS? – Ruban Savvy Nov 5 '14 at 17:53
  • Because i need connect to other ports, not http/s ports, and need a load balancer – hellb0y77 Nov 5 '14 at 18:01
  • 1
    load 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 – guido Nov 5 '14 at 18:14
11

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.