haproxy http внешний интерфейс, серверная часть

Мне нужно использовать haproxy для прослушивания порта 80 и переслать запрос, если он соответствует роли, для которой я сделал это, но я не знаю, как я могу сказать, чтобы использовать серверную часть пробера

frontend httpfw
bind *:80
mode http
acl # what I must write here to defend a domain like test1.com
acl # what I must write here to defend a domain like test2.com

use_backend httptest1 if # how can I told to use this backend if the request comes from test1.com
use_backend httptest2 if # how can I told to use this backend if the request come from test2.com

backend httptest1
mode http
balance source
server httptest1 1.1.1.1:80 



backend httptest2
mode http
balance source
server httptest2 2.2.2.2:80 

Спасибо:)

1 ответ

Решение

Следующее должно направить трафик к соответствующим бэкэндам, в приведенном вами примере:

## Look at host header
acl host_test1 hdr(host) -i test1.com
acl host_test2 hdr(host) -i test2.com

## figure out which one to use depending on the criteria above
use_backend httptest1 if host_test1
use_backend httptest2 if host_test2
Другие вопросы по тегам