有人能帮我配置一下代理吗?
在同一台服务器上,多个端口用于不同的应用程序,我想为它们创建配置:
例如,如果我输入web浏览器test.testdev.com,我希望重定向到192.168.24.121:8080,如果输入test.testdev.com/test/api,我想转到192.168.24.121:10000/test/api。
我的配置
acl testaaa_url hdr_dom(host) -i test.testdev.com
acl testbbb_url hdr_end(host) -i test.testdev.com/test-test
use_backend testaaa if_testaaa_url
user_backend testbbb if testbbb_url
backend testaaa
mode http
server testaaa 192.168.24.121:8080
backend testbbb
mode http
server testbbb 192.168.24.121:10000发布于 2021-05-14 05:29:19
您的ACL不计算。两者都没有"user_backend“设置。
acl testaaa_url hdr_dom(host) -i test.testdev.com
acl testbbb_url hdr_end(host) -i test.testdev.com/test-test
use_backend testaaa if_testaaa_url
user_backend testbbb if testbbb_url
backend testaaa
mode http
server testaaa 192.168.24.121:8080
backend testbbb
mode http
server testbbb 192.168.24.121:10000使用第二个ACL,您将尝试在主机头的末尾(因此是"hdr_end")匹配“test.testdev.com/test”。但是你的主机头只有"test.testdev.com“。
您可能正在寻找的ACL可能是:
acl testbbb_url path -i -m beg /test-test匹配任何HTTP资源匹配/测试-测试。
然后可以将ACL组合起来。和操作符如下:
use_backend testbbb if testaaa_url testbbb_url这样,两个ACL都必须为true,条件才能变为true并转发到testbbb。(意思是:主机头必须匹配"test.testdev.com“,而HTTP资源的开头必须匹配"/test-test”。
您最终会得到这样的粗略配置:
acl testaaa_url hdr_dom(host) -i test.testdev.com
acl testbbb_url path -i -m beg /test-test
use_backend testbbb if testaaa_url testbbb_url
use_backend testaaa if testaaa_url
backend testaaa
mode http
server testaaa 192.168.24.121:8080
backend testbbb
mode http
server testbbb 192.168.24.121:10000一个很好的起点是ACL的HAProxy简介和后续文献官方文件中的ACL部分。
https://stackoverflow.com/questions/67520759
复制相似问题