如何将所有 URL 重定向到 HAProxy 中的一个 URL?
如果 URL 不是www.mysite.com
.,它应该重定向到www.mysite.com
.
您可以使用
acl example hdr_dom(host) -i www.example.com
use_backend example_backend if example
backend example_backend
mode http
option httpchk OPTION /
option redispatch
option httpclose
option forwardfor
balance roundrobin
server example.com 10.200.1.47:80 maxconn 500
希望这能解决!!!
这应该适合你
# mysite.com
acl is_mysite hdr_end(host) -i www.mysite.com
use_backend srv_mysite if is_mysite
# All otherserver
default_backend srv_othersite
backend srv_mysite
balance roundrobin
cookie SERVERID insert nocache indirect
option httpchk HEAD /check.txt HTTP/1.0
option httpclose
option forwardfor
server Local 192.168.10.32:80 cookie Local
backend srv_othersite
balance roundrobin
cookie SERVERID insert nocache indirect
option httpchk HEAD /check.txt HTTP/1.0
option httpclose
option forwardfor
server Local 192.168.10.40:80 cookie Local
这将重定向用户请求www.mysite.com
和192.168.10.32
所有其他请求192.168.10.40