https连接方式,参考配置信息如下:
# 虚拟主机配置02:HTTPS虚拟主机
server {
# 监听的端口号
listen 6668 ssl;
# 监听的IP地址或域名,多个域名之间用空格分开,支持通配符 *.baidu.com、www.baidu.*
server_name www.xxx.com;
# ssl证书的pem文件路径
ssl_certificate /home/cert.pem;
# ssl证书的key文件路径
ssl_certificate_key /home/cert.key;
# 设置共享会话缓存大小,默认1m
ssl_session_cache shared:SSL:10m;
# 设置会话超时时间
ssl_session_timeout 5m;
# 配置SSL加密算法,默认"HIGH:!aNULL:!MD5"
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
# 优先采取服务器算法
ssl_prefer_server_ciphers on;
# 匹配"/websocket/"规则
location /websocket/ {
# 转发地址
proxy_pass http://localhost:9068;
proxy_http_version 1.1;
# 设置读取超时时间(单位:秒,默认60),避免nginx超时
proxy_read_timeout 7200;
proxy_redirect off;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header X-real-ip $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
}
}
websocket连接地址: wss://www.xxx.com:6668/websocket/u30001