I have HAProxy acting as a proxy in front of:
- An NGinx instance
- An in-house load balancer in front of multiple dynamic services exposed with socket.io (websockets)
My problem is that from time to time my connections are proxied correctly to my socket.io cluster, and then randomly it fallsback to routing to NGinx which obviously is annoying and meaningless since NGinx isn't mean't to handle the request.
This happens when requesting for URLs of the format :
There's an ACL in the HAProxy config to match the '/backends/*' path.
Here's a simplified version of my HAProxy config (removed extra unrelated entries and changed names):
global daemon maxconn 4096 user haproxy group haproxy nbproc 4 defaults mode http timeout server 86400000 timeout connect 5000 log global #this frontend interface receives the incoming http requests frontend http-in mode http #process all requests made on port 80 bind *:80 #set a large timeout for websockets timeout client 86400000 # Default Backend default_backend www_backend # Loadfire (socket cluster) acl is_loadfire_backends path_beg /backends use_backend loadfire_backend if is_loadfire_backends # NGinx backend backend www_backend server www_nginx localhost:12346 maxconn 1024 # Loadfire backend backend loadfire_backend option forwardfor # This sets X-Forwarded-For option httpclose server loadfire localhost:7101 maxconn 2048
It's really quite confusing for me why the behaviour appears to be "random", since being hard to reproduce it's hard to debug.
I appreciate any insight on this.