基于单域和多路径重定向haproxy,后端保留原始路径

时间:2018-10-25 09:53:28

标签: url-rewriting haproxy

我正在尝试使用同一子域访问各种后端; 我想根据路径进行重定向:

https://foo.mydomain.com/abc/ -> http://abc-server/
https://foo.mydomain.com/xyz/ -> http://xyz-server/

问题在于,如果后端服务器引用的网址为:

/baa/index.html

客户端浏览器将尝试检索:

https://foo.mydomain.com/baa/index.html

当我需要它来检索此页面以将其定向到“ abc-web”后端时:

https://foo.mydomain.com/abc/baa/index.html

我的部分haproxy.cfg显示如下:

frontend https
    bind *:443 ssl crt /etc/letsencrypt/....<my domain pem file>
    acl host_foo hdr(host) -i foo.mydomain.com
    acl path_app_abc path_beg /abc/
    use_backend abc-web if host_foo path_app_abc


backend abc-web
    mode http
    server abc-web-1 abc-server:80
    reqrep ^([^\ :]*)\ /abc/(.*)     \1\ /\2

0 个答案:

没有答案