Redirect 如何使用haproxy实现负载平衡和重定向

Redirect 如何使用haproxy实现负载平衡和重定向,redirect,load-balancing,haproxy,Redirect,Load Balancing,Haproxy,两台服务器上的内容都位于 我已使用以下配置块配置haproxy listen webfarm 0.0.0.0:8080 mode http stats enable stats uri /haproxy?stats balance roundrobin option httpclose option forwardfor server webserver01 192.168.1.10:88 check server webserve

两台服务器上的内容都位于 我已使用以下配置块配置haproxy

listen webfarm 0.0.0.0:8080
    mode http
    stats enable
    stats uri /haproxy?stats
    balance roundrobin
    option httpclose
    option forwardfor
    server webserver01 192.168.1.10:88 check
    server webserver02 192.168.1.20:88 check

如何让haproxy进一步重定向到目录?我试图通过apache在本地执行重定向,但我得到的只是循环。

这是未经测试的,但您可能正在寻找类似的东西:

frontend my_frontend
    mode http
    bind *:8080
    stats enable
    stats uri /haproxy?stats
    default_backend my_backend

backend my_backend
    balance roundrobin
    option httpclose
    option forwardfor

    reqrep ^(.*)     /web/portal\1

    server webserver01 192.168.1.10:88 check
    server webserver02 192.168.1.20:88 check
关键的更改是接收请求的uri并在其前面加上
/web/portal
(至少它应该这样做)

很抱歉,它的格式与您的示例不同,但我只是从我的一些配置文件中复制了它并对其进行了更改。让我知道这是否适合你的情况