我正在尝试使用自签名SSL在一个自托管服务器上部署项目。
使用NGINX反向代理HTTP->HTTPS重定向。
服务器部分工作,例如,通道无法连接到“事件流”。
见printscreen:

我们的NGINX设置有什么问题?!
在调试服务器时,我发现defineGetter返回HTTP协议,尽管我们运行在反向代理后面:

我在运行npm start之前添加了环境变量
export NODE_TLS_REJECT_UNAUTHORIZED=0 请参阅我们的NGINX设置:
server {
listen 443 ssl;
server_name servername;
ssl_certificate /tmp/ssl_key/crt/servername.crt;
ssl_certificate_key /tmp/ssl_key/crt/servername.rsa;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!MD5;
#...
location / {
proxy_pass http://localhost:3000;
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;
proxy_redirect http:// https://;
}
}发布于 2019-06-18 14:43:21
根本原因是在客户端访问期间“没有事件源的响应”。
通过更改NGINX反向代理设置来解决问题。
基于那篇文章EventSource /Server-通过Nginx发送事件。
我们的新NGINX设置如下:
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection '';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_redirect http:// https://;
chunked_transfer_encoding off;
proxy_buffering off;
proxy_cache off;
}https://stackoverflow.com/questions/56643995
复制相似问题