Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

i'm trying to set up a server structure for an application i'm building in Node.js with socket.io.

My setup is:

HAProxy frontend forward to

     -> apache2 as default backend (or nginx, is apache in this local test)

     -> node.js app if the url has socket.io in the request AND a domain name

i have something like:

  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

The problem comes when i made a request to something like www.chaturl.com/index.html it load perfectly but fails to loads the socket.io files (www.chaturl.com/socket.io/socket.io.js) why it redirect to apache (and should redirect to the node.js app that serve the files). The weird thing is that if i access directly to the socket.io file, after refreshing a few times, it loads, so i suppose is "caching" the forwarding for the client when it makes the first request and reach the apache server.

Any suggestion of how this can be solved? or what i can try or look about this?

share|improve this question
    
HAProxy doesn't cache any content. I suspect the problem lies in the acl rule, where after "-i" –  Sameer Nov 24 '12 at 4:14
    
any more details of how that is? i changed the rules to make it more straightforward, simpler, only checking for "socket.io" and not the server domain and i still see that if i make a request to the socket.io.js file first, and then i ask for like index.html, it redirects me to socket.io, after a few refresh it come back and loads the index.html from apache2 but them again, fails to load socket.io files :( –  shadow_of__soul Nov 24 '12 at 12:08
add comment

1 Answer

up vote 1 down vote accepted

"option http-server-close" is missing from your configuration. Add it and your problems will go away.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.