Node.js ERR_SSL_PROTOCOL_错误,即使配置了我的nginx配置
我用nginx在数字海洋上部署了一个应用程序。我已经反向代理了我的前端端口8081,并使用Let's Encrypt使其具有ssl安全性。现在我需要保护端口8080上的websocket服务器,以防止它给我这个错误“ERR\u SSL\u PROTOCOL\u error” 这是我当前的nginx配置Node.js ERR_SSL_PROTOCOL_错误,即使配置了我的nginx配置,node.js,ssl,nginx,websocket,proxy,Node.js,Ssl,Nginx,Websocket,Proxy,我用nginx在数字海洋上部署了一个应用程序。我已经反向代理了我的前端端口8081,并使用Let's Encrypt使其具有ssl安全性。现在我需要保护端口8080上的websocket服务器,以防止它给我这个错误“ERR\u SSL\u PROTOCOL\u error” 这是我当前的nginx配置 server { listen 80; listen 443 ssl; root /var/www/html; index index.html index.ht
server {
listen 80;
listen 443 ssl;
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
server_name mywebsite.com www.mywebsite.com; #managed by Certbot
ssl_certificate /etc/letsencrypt/live/mywebsite/fullchain.pem; #managed by Certbot
ssl_certificate /etc/letsencrypt/live/mywebsite/privkey.pem; #managed by Certbot
location / {
proxy_pass http://localhost:8081;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
location /websocket/ {
proxy_pass http://localhost:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
include /etc/letsencrypt/options-ssl-nginx.conf; #managed by Certbot
include /etc/letsencrypt/ssl-dhparams.pem; #managed by Certbot
}
我错过什么了吗?我到处都找过了,我能告诉你这个设置应该是正确的吗?从外部访问websocket的URL是什么?为什么不设置主机头呢?我无法从任何URL访问websocket。我试图设置websocket的主机头,但什么也没有发生。我如何设置以便可以使用url访问我的websocket?不起作用。”
https://mywebsite.com:8080
不起作用”-这是意料之中的,正是我问您如何尝试访问websocket的原因。您已经显式地将nginx配置为代理websocket,因此访问它的正确URL应该是https://mywebsite.com/websocket/
。这给了我502个坏网关。我需要更改index.js,以便通过该url访问它?对不起,它不应该是https://...
但是当然wss://mywebsite.com/websocket/
从外部访问websocket的URL是什么?为什么不设置主机头呢?我无法从任何URL访问websocket。我试图设置websocket的主机头,但什么也没有发生。我如何设置以便可以使用url访问我的websocket?不起作用。”https://mywebsite.com:8080
不起作用”-这是意料之中的,正是我问您如何尝试访问websocket的原因。您已经显式地将nginx配置为代理websocket,因此访问它的正确URL应该是https://mywebsite.com/websocket/
。这给了我502个坏网关。我需要更改index.js,以便通过该url访问它?对不起,它不应该是https://...
但是当然wss://mywebsite.com/websocket/