我的配置文件:HAProxy的不匹配路徑(與express.js&Socket.IO)
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匹配一切。當我的網絡應用程序請求http://myapp.com/socket.io/1/?t=1335831853491時,它返回一個404,並且標題顯示來自Express的響應。奇怪的是,當我蜷縮-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的任何想法運行?
Willy,1天超時似乎是socket.io的鼓勵http://stackoverflow.com/questions/4360221/haproxy-websocket-disconnection/4737648#4737648。也許發佈在那裏和https://github.com/learnboost/socket.io/wiki/可能會幫助別人不會犯同樣的錯誤,我做到了!感謝您的幫助。 – LDK