HAProxy:将后端更改为路径?
HAProxy: change backend as path?
我是 haproxy 新手
haproxy 在使用子路径时是否可以使用后端?
例如
test.app.com/a/ > appa.example.com:5000/
test.app.com/b/ > appb.example.com:5001/
所以
http://test.app.com/a/index.html > appa.example.com:5000/index.html
http://test.app.com/b/testing/ > appb.example.com:5001/testing/
是的,是的。路径的 ACL,如 path_beg
和 use_backend
以根据请求路由流量。在后端使用 http-request set-path
.
修改路径
下面的简化示例:
frontend http
bind *:80
acl url_a path_beg -i /a/
acl url_b path_beg -i /b/
use_backend backend-a if url_a
use_backend backend-b if url_b
backend backend-a
http-request set-path %[path,regsub(^/a/,/,g)]
server a appa.example.com:5000
backend backend-b
http-request set-path %[path,regsub(^/b/,/,g)]
server b appb.example.com:5001
我是 haproxy 新手 haproxy 在使用子路径时是否可以使用后端? 例如
test.app.com/a/ > appa.example.com:5000/
test.app.com/b/ > appb.example.com:5001/
所以
http://test.app.com/a/index.html > appa.example.com:5000/index.html
http://test.app.com/b/testing/ > appb.example.com:5001/testing/
是的,是的。路径的 ACL,如 path_beg
和 use_backend
以根据请求路由流量。在后端使用 http-request set-path
.
修改路径
下面的简化示例:
frontend http
bind *:80
acl url_a path_beg -i /a/
acl url_b path_beg -i /b/
use_backend backend-a if url_a
use_backend backend-b if url_b
backend backend-a
http-request set-path %[path,regsub(^/a/,/,g)]
server a appa.example.com:5000
backend backend-b
http-request set-path %[path,regsub(^/b/,/,g)]
server b appb.example.com:5001