HAProxy不保持HTTP连接打开

我有一个Node.js服务器使用服务器发送事件(SSE)来允许推送通知连接的Web客户端。 当浏览器直接与节点对话时,它工作的很好。

但是,当我把haproxy放在中间时,为了达到其他要求,生产线必须每隔30秒closures并重新打开(感谢SSE的自动重新连接)。 我已经改变了,并尝试了我所知道的一切,并可以在haproxyconfiguration中在线find。

大多数信息都在那里,在他们的文档示例中涉及套接字,但是对于SSE的支持却很less。 它应该支持SSE的持久HTTP连接吗? 如果是的话,configuration它有什么窍门?

我的configuration如下:全局守护进程#最大并发连接数maxconn 4096#删除端口绑定后的权限用户nobody组nogroup#在文件中存储进程的pid pidfile /var/run/haproxy.pid#为stats stats创build此套接字socket /无功/运行/socketsHAProxy的

defaults log global mode http # disable logging of null connections option dontlognull # I've tried all these to no avail #option http-server-close #option httpclose option http-keep-alive # Add x-forwarded-for header to forward clients IP to app option forwardfor # maximum time to wait for a server connection to succeed. Can be as low as few msec if Haproxy and server are on same LAN. timeout connect 1s # maximum inactivity time on client side. Recommended to keep it same as server timeout. timeout client 24d # maximum time given to server to respond to a request timeout server 24d # Long timeout for WebSocket connections. timeout tunnel 8h # timeout for keep alive timeout http-keep-alive 60s # maximum time to wait for client to send full request. Keep it like 5s for get DoS protection. timeout http-request 5s # enable stats web interface. very helpful to see what's happening in haproxy stats enable # default refresh time for web interface stats refresh 30s # this frontend interface receives the incoming http requests and forwards to https then handles all SSL requests frontend public # HTTP bind :80 # by default, all incoming requests are sent to Node.js default_backend node_backend # redirect to the SSE backend if /ionmed/events (eventum #????) acl req_sse_path path_beg /ionmed/events use_backend node_sse_backend if req_sse_path # redirect to the tomcat backend if Time Clock, ViewerJS, Spell Checker, Tomcat Manager, or eScripts (eventum #1039, #1082) acl req_timeclock_path path_beg /TimeClock/ acl req_manager_path path_beg /manager/ acl req_spelling_path path_beg /jspellEvolution/ acl req_escripts_path path_beg /ionmed/escripts use_backend tomcat_backend if req_timeclock_path or req_manager_path or req_spelling_path or req_escripts_path # for displaying HAProxy statistics acl req_stats path_beg /stats use_backend stats if req_stats # node backend, transfer to port 8081 backend node_backend # Tell the backend that this is a secure connection, # even though it's getting plain HTTP. reqadd X-Forwarded-Proto:\ https server node_server localhost:8081 # node SSE backend, transfer to port 8082 backend node_sse_backend # Tell the backend that this is a secure connection, # even though it's getting plain HTTP. reqadd X-Forwarded-Proto:\ https server node_sse_server localhost:8082 # tomcat backend, transfer to port 8888 backend tomcat_backend # Tell the backend that this is a secure connection, # even though it's getting plain HTTP. reqadd X-Forwarded-Proto:\ https server tomcat_server localhost:8888