Nginx反代Websocket需要注意的参数

NginxWebsocket发布于2021-01-02 / 更新于2021-01-02 07:11

前言

对外提供的Websocket基本上都是基于wss协议,一般通过Nginx+SSL证书进行反代

反代参数

如果没有设置代理连接及操作时间等待时间, 默认5分钟内如果没有发送和推送消息则会断开, 在某些业务有时候空置期会超过5分钟, 以下时间参数可根据业务进行调整

参数示例

location / {
      proxy_pass http://127.0.0.1:10006;
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "upgrade";
      proxy_read_timeout 1200s;
      proxy_connect_timeout 1200s;
      proxy_send_timeout 1200s;
	}
I am a full-stack independent development engineer from China. I love to participate in open source and focus on developing the Web, iOS App & Android App (React Native), desktop applications (Eletron), crawlers, back-end services, system architecture

讨论

暂无评论

目录

1.前言
2.反代参数
3.参数示例