天天看點

使用nginx配置支援WebSocket通路

使用nginx配置支援WebSocket通路

在server{}外面增加配置

map $http_upgrade $conn_upgrade {
  default upgrade;
  '' close;
}
           

轉發接口的配置檔案中增加一下配置,例如:

location /api {           

        proxy_read_timeout 500s; #不是必須
        proxy_send_timeout 500s; #不是必須
        #更新http1.1到 websocket協定
        proxy_http_version 1.1;
        proxy_set_header Connection $conn_upgrade;
        proxy_set_header Upgrade $http_upgrade;
    }
           

繼續閱讀