Nginx Websockets 和 keepalive_timeout

Mar*_*n29 5 nginx websocket

我使用 Nginx (nginx/1.10.2) 作为后端服务器的反向代理。我有网络套接字,需要确保长期连接。http我在配置部分有以下几行:

keepalive_timeout 0;
proxy_read_timeout 5d;
proxy_send_timeout 5d;
Run Code Online (Sandbox Code Playgroud)

我根据文档了解 proxy_read 和 proxy_sends 行。然而,这是怎么keepalive_timeout发生的呢?我应该将 keepalive_timeout 设置为 0 以便基本上没有超时吗?或者我应该将其设置为一个高值?

这实际上有什么作用?我没有真正找到明确此参数的文档:http://nginx.org/en/docs/http/ngx_http_core_module.html#keepalive_timeout

另外,设置或禁用 keepalive_timeout 将如何影响我正在加载的其他静态页面?是否可以仅为 websocket 设置这些超时值?因为文档将它们放在 http 模块下,所以我不确定是否可以将它们设置在特定位置:

   location /websock {
      # limit connections to 10
      limit_conn addr 10;
      proxy_set_header Host $host;
      proxy_pass http://backends;
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "upgrade";

   }
Run Code Online (Sandbox Code Playgroud)