ws to wss

background

Websocket is used in the WeChat applet, and when it goes online, it is found that only wss is supported when configuring the interface

Concrete operation

Using nginx to convert ws to wss can be compared to http to https. The following operations are performed on the basis that http has been successfully converted to https. http to https (ngxin configuration is similar)

ws://192.168.10.11:9152/projectName/wsdemo

If the ws path is as above, the configuration is as follows

location /projectName/wsdemo {
        proxy_pass http://192.168.10.11:9152$request_uri;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
 }

ngxin -s reload will do.

Note: Since the maximum idle time in nginx is 60s, it is best to set a heartbeat mechanism

Guess you like

Origin blog.csdn.net/weiqiang915/article/details/125724591