为什么 haproxy path_beg 仅在我不访问默认站点时才起作用?
我已配置 haproxy 将路径“/rawman”重定向到服务器上的端口 8080。它第一次工作,但是一旦我访问默认站点,它就停止工作。默认站点在 apache 上使用 mod_rewrite 运行,并且它正在捕获无效请求(使用 codeigniter),因此当我访问 http://mysite.com/rawman?foo=bar 我看到默认站点。
This is my haproxy config:
global
log 127.0.0.1 local0
log 127.0.0.1 local1 notice
maxconn 4096
user haproxy
group haproxy
daemon
defaults
log global
mode http
option httplog
option dontlognull
retries 3
option redispatch
maxconn 2000
contimeout 5000
clitimeout 50000
srvtimeout 50000
frontend http_proxy
bind 0.0.0.0:8090
acl is_ast path_beg /rawman
use_backend ast if is_ast
default_backend mysite
backend ast
server ast 0.0.0.0:8080
backend mysite
server local 0.0.0.0:80
I have configured haproxy to redirect the path "/rawman" to port 8080 on my server. It works the first time, but as soon as I visit the default site it stops working. The default site is running on apache with mod_rewrite and it is catching invalid requests (using codeigniter) so instead of seeing the redirected site when I visit http://mysite.com/rawman?foo=bar I see the default site.
This is my haproxy config:
global
log 127.0.0.1 local0
log 127.0.0.1 local1 notice
maxconn 4096
user haproxy
group haproxy
daemon
defaults
log global
mode http
option httplog
option dontlognull
retries 3
option redispatch
maxconn 2000
contimeout 5000
clitimeout 50000
srvtimeout 50000
frontend http_proxy
bind 0.0.0.0:8090
acl is_ast path_beg /rawman
use_backend ast if is_ast
default_backend mysite
backend ast
server ast 0.0.0.0:8080
backend mysite
server local 0.0.0.0:80
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试在
srvtimeout
行之后设置option httpclose
。如果您不这样做,那么 haproxy 将使用目标服务器的 keepalive 设置。一旦您访问主站点,连接就会打开并保持打开状态,并且在您的下一个请求时,haproxy 会哦,这不是很好吗:我有一个开放的连接。让我们使用它,即使它不应该。设置 httpclose 选项后,它始终关闭连接,确保每个新请求使用正确的连接。
我浪费了 3 个小时的时间来解决这个问题。
Try setting
option httpclose
after thesrvtimeout
line.If you don't do that then haproxy uses the target server's keepalive setting. Once you visit the main site the connection is opened and kept open, and on your next request haproxy goes oh isn't that nice: I have an open connection. Lets just use it even though it shouldn't. With the httpclose option set it always closes the connection, ensuring that each new request uses the right connection.
Lost 3 hours of my life figuring that out.