websocket连接https和nginx问题
-
连接https,需使用wss://
-
nginx需配置
http {
...
# 自定义变量 $connection_upgrade
map $http_upgrade $connection_upgrade {
default keep-alive; #默认为keep-alive 可以支持 一般http请求
'websocket' upgrade; #如果为websocket 则为 upgrade 可升级的。
}
server {
...
location /websocket/ {
proxy_pass http://127.0.0.1/websocket/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade; #此处配置 上面定义的变量
proxy_set_header Connection $connection_upgrade;
}
}
}
谢 https://www.csdn.net/tags/NtjaAgxsMTg2ODktYmxvZwO0O0OO0O0O.html