Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does haproxy path_beg only work if I don't visit default site?

Tags:

apache

haproxy

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
like image 941
Jesse Avatar asked Jun 01 '11 20:06

Jesse


1 Answers

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.

like image 114
Femi Avatar answered Oct 06 '22 07:10

Femi