@Gring76

Как в haproxy работать с поддоменами?

Доброго времени суток всем :-)

Есть машина с виртуализацией, несколько виртуалок с web сервисами.
С целью экономии ipv4 решил использовать haproxy
Все работало нормально, прока не понадобилось еще 1 виртуалку прикрутить.
И тут начались проблемы.
Haproxy переадресовывает не на ту ВМ.

Вот мой конфиг

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


При запросе test4.mysite.com открывается почему то
mysite.com
Все другие сайты test1.mysite.com test2.mysite.com www.mysite.com mysite.com открываются как и планировалось

У меня есть "подозрение" что как то не правильно прописал главный домен mysite.com

Подскажите в какую сторону копать?
  • Вопрос задан
  • 1573 просмотра
Пригласить эксперта
Ответы на вопрос 1
@Gring76 Автор вопроса
Если убрать из конфига строки о домене 2-го уровня - то все работает как нужно

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


Но при этом не открывается домен без приставки www

Вроде как нашел решение.
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
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы