0

我的配置文件:

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 上运行。有什么想法吗?

4

2 回答 2

1

在这里找到答案:

https://serverfault.com/questions/248897/haproxy-access-list-using-path-dir-having-issues-with-firefox

“我们必须将“选项 http-server-close”添加到您的默认部分,它应该可以工作。”

于 2012-05-01T03:57:45.933 回答
1

同意楼上的回答。顺便说一句,您不应该使用 1 天的超时来建立 TCP 连接(超时连接),这根本没有意义,并且会在您的服务器出现故障时导致连接累积。应该立即建立连接(尤其是本地连接)。我倾向于为连接设置 5s 超时,即使在慢速网络上也足够了。

关于其他长时间超时,我计划实施“超时隧道”,以便用户不必为正常流量使用那么大的超时。

于 2012-05-06T09:33:37.980 回答