Hi David, On Sat, Nov 24, 2012 at 09:26:56AM -0300, david rene comba lareu wrote: > Hi everyone, > > i'm little disappointed with a problem i'm having trying to configure > HAproxy in the way i need, so i need a little of help of you guys, > that knows a lot more than me about this, as i reviewed all the > documentation and tried several things but nothing worked :(. > > basically, my structure is: > > HAproxy as frontend, in 80 port -> forwards by default to webserver > (in this case is apache, in other machines could be nginx) > -> depending the domain > and the request, forwards to an Node.js app > > so i have something like this: > > 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 > maxconn 2000 > contimeout 5000 > clitimeout 50000 > srvtimeout 50000 > > > frontend all 0.0.0.0:80 > timeout client 5000 > default_backend www_backend > > acl is_soio url_dom(host) -i socket.io #if the request contains socket.io > > acl is_chat hdr_dom(host) -i chaturl #if the request comes from chaturl.com > > use_backend chat_backend if is_chat is_soio > > backend www_backend > balance roundrobin > option forwardfor # This sets X-Forwarded-For > timeout server 5000 > timeout connect 4000 > server server1 localhost:6060 weight 1 maxconn 1024 check #forwards to apache2 > > backend chat_backend > balance roundrobin > option forwardfor # This sets X-Forwarded-For > timeout queue 50000 > timeout server 50000 > timeout connect 50000 > server server1 localhost:5558 weight 1 maxconn 1024 check #forward to > node.js app > > my application uses socket.io, so anything that match the domain and > has socket.io in the request, should forward to the chat_backend. > > The problem is that if i load directly from the browser, let say, the > socket.io file (it will be something like > http://www.chaturl.com/socket.io/socket.io.js) loads perfectly, but > then when i try to load index.html (as > http://www.chaturl.com/index.html) most of the times, is still > redirect to socket.io. after refreshing a few time, it finally loads > index.html, but then, doesn't load the socket.io.js file inserted in > the file (why it redirect to the apache server, and not the node.js > app). so as i said, it sort of "caching" the request. > > i tried several ACL combinations, i disabled the domain check, only > checking for socket.io but is still the same. Reading again the > documentation i tried to use hdr_dir, hdr_dom, with other headers as > URI, url, Request (btw, where i can find a list of headers supported > by the layer 7 ACL ?). > > so, nothing worked, if someone could help me, and point me to the > right direction, i would be really grateful :D
You're missing "option http-server-close" in your config, so after the first request is done, haproxy switches to tunnel mode and maintains the client-server connection without inspecting anything in it. Regards, Willy