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
Try setting option httpclose
after the srvtimeout
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With