因为服务器配置了https环境,而且也需要https,使用了nginx
于是发现dwebsocket不灵了,总报错是一个普通的http请求
后来发现是需要配置nginx,请按以下两步操作
1,在http区域内添加如下代码
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
2,在location内添加如下代码
#proxy_http_version 1.1;
#proxy_set_header Upgrade $http_upgrade;
#proxy_set_header Connection "upgrade";
完整的代码片段如下:
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
root /usr/share/nginx/html;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
#暂时不配置80端口的代理
#add_header Cache-Control no-cache;
#proxy_pass http://172.26.153.188:8000;
#proxy_set_header real-ip $remote_addr;
#proxy_set_header Host $http_host;
#proxy_http_version 1.1;
#proxy_set_header Upgrade $http_upgrade;
#proxy_set_header Connection "upgrade";
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
https同样的配置在location 里同样配置即可
爆款云服务器s6 2核4G 低至0.46/天,具体规则查看活动详情