HAProxy is caching the forwarding?

Posted by shadow_of__soul on Server Fault See other posts from Server Fault or by shadow_of__soul
Published on 2012-11-24T03:06:58Z Indexed on 2012/11/24 5:07 UTC
Read the original article Hit count: 341

Filed under:
|
|
|

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?

© Server Fault or respective owner

Related posts about apache2

Related posts about haproxy