英文:
HAPROXY how to sne drequest from port 80 to backend 80 nad port 443 to backned 443, all request layer 7
问题
如何设置haproxy以根据域名发送第7层请求(端口80和443)到正确的后端?
以下是我的测试haproxy配置文件中的示例:
frontend example.com
bind :80,:443
acl ACL_example.com hdr(host) -i example.com www.example.com
use_backend example_80 if ACL_example.com
use_backend example_443 if { dst_port 443 }
backend example_80
balance roundrobin
server 001xx000x017 10.1.0.17:80 check
backend example_443
balance roundrobin
server 001xx000x017 10.1.0.17:443 check
提前感谢您的帮助。
英文:
How can I set up haproxy to send layer 7 requests (by domain name) to the right backedn (port 80 and 443)
Here is the an example from my test haproxy config file:
frontend example.com
bind :80,:443
acl ACL_example.com hdr(host) -i example.com www.example.com
use_backend example_80 if ACL_example.com
use_backend example_443 if { dst_port 443 }
backend example_80
balance roundrobin
server 001xx000x017 10.1.0.17:80 check
backend example_443
balance roundrobin
server 001xx000x017 10.1.0.17:443 check
In advance, many thanks for the help.
答案1
得分: 0
我明白了,这是现在正常运行的haproxy实际配置文件的布局:
前端 http_80
42 绑定 :80
41 # example.com
40 acl ACL_example_com hdr(host) -i example.com www.example.com
39
38 # sc.example.com
37 acl ACL_sc_example_com hdr(host) -i sc.example.com www.sc.example.com
36
35 # 001x.example.com
34 acl ACL_001x_example_com hdr(host) -i 001x.example.com www.001x.example.com
33
32 # example.com
31 acl ACL_example_com hdr(host) -i example.com www.example.com
30
29 # 001x01dns.example.com
28 acl ACL_001x01dns_example_com hdr(host) -i 001x01dns.example.com www.001x01dns.example.com
27
26 # example.tech
25 acl ACL_example_tech hdr(host) -i example.tech www.example.tech
24
23
22 如果 ACL_example_com 使用后端 example_80
21 如果 ACL_sc_example_com 使用后端 sc_example_80
等等...
相同的逻辑适用于端口443。现在运行得非常完美
英文:
I figured it out, this is the layout of the actual config file for haproxy that works now:
frontend http_80
42 bind :80
41 # example.com
40 acl ACL_example_com hdr(host) -i example.com www.example.com
39
38 # sc.example.com
37 acl ACL_sc_example_com hdr(host) -i sc.example.com www.sc.example.com
36
35 # 001x.example.com
34 acl ACL_001x_example_com hdr(host) -i 001x.example.com www.001x.example.com
33
32 # example.com
31 acl ACL_example_com hdr(host) -i example.com www.example.com
30
29 # 001x01dns.example.com
28 acl ACL_001x01dns_example_com hdr(host) -i 001x01dns.example.com www.001x01dns.example.com
27
26 # example.tech
25 acl ACL_example_tech hdr(host) -i example.tech www.example.tech
24
23
22 use_backend example_80 if ACL_example_com
21 use_backend sc_example_80 if ACL_sc_example_com
ETC...
same logic is for port 443. Works perfect now
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论