Answer the question
In order to leave comments, you need to log in
How to work with subdomains in haproxy?
Good day to all :-)
There is a machine with virtualization, several virtual machines with web services.
In order to save ipv4, I decided to use haproxy.
Everything worked fine, for the time being, I didn’t need to fasten 1 more virtual machine.
And then the problems began.
Haproxy is redirecting to the wrong VM.
Here is my config
frontend http_frontend
bind 1xx.yy.zzz.138:80
mode http
option httpclose
acl is_mytest1 hdr_end(host) -i test.mysite.com
use_backend mytest1_web if is_mytest1
acl is_mytest2 hdr_end(host) -i test2.mysite.com
use_backend mytest2_web if is_mytest2
acl is_mytest3 hdr_end(host) -i mysite.com
use_backend mytest3_web if is_mytest3
acl is_mytest3 hdr_end(host) -i www.mysite.com
use_backend mytest3_web if is_mytest3
acl is_mytest4 hdr_end(host) -i test4.mysite.com
use_backend mytest4_web if is_mytest4
backend mytest1_web
mode http
cookie SERVERID insert indirect nocache
server mytestweb1 192.168.200.102:80 check cookie mytestweb1
backend mytest2_web
mode http
cookie SERVERID insert indirect nocache
server mytestweb2 192.168.200.101:80 check cookie mytestweb2
backend mytest3_web
mode http
cookie SERVERID insert indirect nocache
server mytestweb3 1xx.yy.xxx.189:80 check cookie mytestweb3
backend mytest4_web
mode http
cookie SERVERID insert indirect nocache
server mytestweb4 192.168.200.104:80 check cookie mytestweb4
Answer the question
In order to leave comments, you need to log in
If you remove the lines about the 2nd level domain from the config, then everything works as it should
acl is_mytest1 hdr_end(host) -i test.mysite.com
use_backend mytest1_web if is_mytest1
acl is_mytest2 hdr_end(host) -i test2.mysite.com
use_backend mytest2_web if is_mytest2
# acl is_mytest3 hdr_end(host) -i mysite.com
# use_backend mytest3_web if is_mytest3
acl is_mytest3 hdr_end(host) -i www.mysite.com
use_backend mytest3_web if is_mytest3
acl is_mytest4 hdr_end(host) -i test4.mysite.com
use_backend mytest4_web if is_mytest4
acl is_mytest1 hdr(host) -i test.mysite.com
use_backend mytest1_web if is_mytest1
acl is_mytest2 hdr(host) -i test2.mysite.com
use_backend mytest2_web if is_mytest2
acl is_mytest3 hdr(host) -i mysite.com
use_backend mytest3_web if is_mytest3
acl is_mytest3 hdr(host) -i www.mysite.com
use_backend mytest3_web if is_mytest3
acl is_mytest4 hdr(host) -i test4.mysite.com
use_backend mytest4_web if is_mytest4
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question