How to divert traffic based on hostname using HAProxy?
Posted
by Bosky
on Server Fault
See other posts from Server Fault
or by Bosky
Published on 2010-01-24T14:42:42Z
Indexed on
2010/03/26
23:53 UTC
Read the original article
Hit count: 199
I've had some initial success with HAProxy setting up a bunch of app servers listening on various other ports.
I now have another webserver listening on one port, and i'd like to what changes to make to my config to flow traffic by hostname as well.
The following is the current setup, assuming:
- my apache webserver is running at examplecom:8001
- my bunch of app servers 0.0.0.0:8081, 0.0.0.0:8082 , 0.0.0.0:8083
global log 127.0.0.1 local0 log 127.0.0.1 local1 notice maxconn 4096 debug #quiet #user haproxy #group haproxy defaults log global mode http option httplog option dontlognull retries 3 redispatch maxconn 2000 contimeout 5000 clitimeout 50000 srvtimeout 50000 listen appservers 0.0.0.0:80 mode http balance roundrobin option httpclose option forwardfor #option httpchk HEAD /check.txt HTTP/1.0 server inst1 0.0.0.0:8081 cookie server01 check inter 2000 fall 3 server inst2 0.0.0.0:8082 cookie server02 check inter 2000 fall 3 server inst3 0.0.0.0:8083 cookie server01 check inter 2000 fall 3 server inst4 0.0.0.0:8084 cookie server02 check inter 2000 fall 3 capture cookie vgnvisitor= len 32
(any other comments on the ^ setup are welcome.)
Now I'd like to continue the same above, but in addition in case - if the hostname is myspecialtopleveldomain<dot>com, then would like to flow traffic to example<dot>com:8001
~B
© Server Fault or respective owner