配置 Nginx 作为 WebSocket 的代理服务器步骤:
首先,找到 Nginx 可执行文件位置
其次,通过 /usr/sbin/nginx -t
命令找到 Nginx 配置文件 nginx.conf
的位置
然后,在配置文件 server
的 location /
中添加
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
最后重启 Nginx 服务或重新加载配置文件。