Http

haproxy http 前端,後端

  • March 9, 2018

我需要使用 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 

謝謝 :)

在您提供的範例中,以下內容應將流量路由到相應的後端:

## 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

引用自:https://serverfault.com/questions/900923