【发布时间】:2012-11-18 22:39:38
【问题描述】:
我安装了 haproxy 1.4,我需要在 haproxy.conf 中配置一个反向代理,将 URL 从 www.somedomain.com 重写为 www.otherdomain.com/bla/ble。我正在写的配置在这里:
acl cpol_acl hdr_dom(host) -i www.somedomain.com
use_backend cpol_srv if cpol_acl
backend cpol_srv
balance leastconn
mode http
option httplog
stick on src
stick-table type ip size 10240k expire 60m
reqirep ^([^\ :]*)\ /(.*) \1\ /bla/ble\2
reqirep ^Host:\ www.somedomain.com Host:\ www.otherdomain.com
server cpol_srv www.otherdomain.com check port 80
这是可行的,但浏览器中的 URL 确实重写为 www.otherdomain.com/bla/ble,这不是我想要的。如果我删除该行
reqirep ^([^\ :]*)\ /(.*) \1\ /bla/ble\2
我只能转发到主机www.otherdomain.com,但浏览器中的URL仍然是www.somedomain.com。
有没有办法在不重写浏览器 URL 的情况下做这种类型的反向代理?
PS:我会做这种 Apache 风格(可行),但机器没有任何 NAT 到外面的世界,只能与 haproxy 通信。
【问题讨论】:
标签: reverse-proxy haproxy