Nginx 配置 WSS 转 WS 详解:示例与最佳实践
以下是一个示例的 Nginx 配置,将 WSS 转为 WS:
server {
listen 443 ssl;
server_name xx.gpde.com;
ssl_certificate /path/to/cert.crt;
ssl_certificate_key /path/to/cert.key;
location /proxy/ {
proxy_pass http://111.56.25.15:6099/oodex/xDeser3;
proxy_set_header Host $host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
}
location / {
return 301 http://$server_name$request_uri;
}
}
server {
listen 80;
server_name xx.gpde.com;
location / {
return 301 https://$server_name$request_uri;
}
}
其中,将 wss://xx.gpde.com:6013/proxy/111.56.25.15:6099/oodex/xDeser3 转为 ws://xx.gpde.com/proxy/111.56.25.15:6099/oodex/xDeser3。该配置文件将在 443 端口上启用 SSL,并将所有请求重定向到 https://xx.gpde.com。proxy_pass 指令将请求转发到目标服务器,并使用 proxy_set_header 指令将必要的头信息设置为协议升级和连接升级。
原文地址: https://www.cveoy.top/t/topic/mU5v 著作权归作者所有。请勿转载和采集!