nginx配置websocket支持wss
Posted nginx
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了nginx配置websocket支持wss相关的知识,希望对你有一定的参考价值。
如下配置nginx
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
upstream websocket {
server 128.190.82.105:8888;
}
server {
listen 8888;
server_name proxy.hello.com;
ssl on;
ssl_certificate /etc/nginx/ssl/hello.com_bundle.crt;
ssl_certificate_key /etc/nginx/ssl/hello.com.key;
ssl_session_timeout 20m;
ssl_verify_client off;
location / {
proxy_pass http://websocket;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
}
WEBSOCKET_URL: 'wss://proxy.hello.com:8888',
image.png
检查nginx.conf正确性:
nginx -t
重新加载配置文件:
nginx -s reload
來源:简书
以上是关于nginx配置websocket支持wss的主要内容,如果未能解决你的问题,请参考以下文章