我的配置文件:
global
maxconn 4096 # Total Max Connections. This is dependent on ulimit
nbproc 2
daemon
log 127.0.0.1 local1 notice
defaults
mode http
frontend all 0.0.0.0:80
timeout client 86400000
default_backend www_backend
acl is_websocket hdr(Upgrade) -i WebSocket
acl is_websocket hdr_beg(Host) -i ws
acl is_websocket path_beg /socket.io
use_backend socket_backend if is_websocket
backend www_backend
balance roundrobin
option forwardfor # This sets X-Forwarded-For
timeout server 30000
timeout connect 4000
server server1 localhost:9001 weight 1 maxconn 1024 check
server server2 localhost:9002 weight 1 maxconn 1024 check
backend socket_backend
balance roundrobin
option forwardfor # This sets X-Forwarded-For
stats enable
timeout queue 5000
timeout server 86400000
timeout connect 86400000
server server1 localhost:5000 weight 1 maxconn 1024 check
据我所知, www_backend 匹配所有内容。当我的 Web 应用程序请求http://myapp.com/socket.io/1/?t=1335831853491时,它返回 404,并且标头显示响应来自 Express。奇怪的是当我做 curl -I http://myapp.com/socket.io/1/?t=1335831853491它返回:
HTTP/1.1 200 OK
Content-Type: text/plain
Connection: keep-alive
当我运行 sudo netstat -lptu 时,我可以确认我的 socket.io 进程正在端口 5000 上运行。有什么想法吗?