使用HAProxy重定向URL

时间:2016-11-25 12:22:38

标签: haproxy http-redirect

我尝试将以下网址https://register.company.xzy定向到https://register.company.xzy/register/supplier?code=

我的haproxy配置包含了一些现有的子域名,并且一直运行良好,但我看不到要让它工作:

frontend https
    bind 10.10.2.150:443 ssl crt /etc/apache2/ssl/star.company.xyz.pem
    mode http
    option httpclose
    option forwardfor
    reqadd X-Forwarded-Proto:\ https

    acl www.company.xyz hdr(host) -i www.company.xyz
    acl portal.company.xyz hdr(host) -i portal.company.xyz
    acl live.company.xyz hdr(host) -i live.company.xyz
    acl register.company.xyz hdr(host) -i register.company.xyz

    use_backend website_live_servers if www.company.xyz
    use_backend website_live_servers if portal.company.xyz
    use_backend application_live_servers if live.company.xyz
    use_backend register_live_servers  if register.company.xyz

backend application_live_servers
    mode http
    cookie SERVERID insert indirect nocache
    server server1 server1.company.xyz:80 check cookie $1

backend register_live_servers
    mode http
    cookie SERVERID insert indirect nocache
    server server2 server2.company.xyz:80 check cookie $1

backend website_live_servers
    mode http
    cookie SERVERID insert indirect nocache
    server server3 server3.company.xyz:80 check cookie $1
    server server3 server3.company.xyz:80 check cookie $2

任何想法或指导?

1 个答案:

答案 0 :(得分:0)

您需要的是重写网址

http-request set-path <fmt> [<condition>]
http-request set-query <fmt> [<condition>]

或重写完整的URI

http-request set-uri <fmt> [<condition>]

rewriting url path