【问题标题】:Nginx SSL reverse proxy doesn't work with websocketNginx SSL 反向代理不适用于 websocket
【发布时间】:2020-11-22 00:19:09
【问题描述】:

我有这个配置:

server {
listen 443 ssl;
listen [::]:443 ssl;

server_name mydomain.com;

ssl_certificate /usr/syno/etc/certificate/ReverseProxy/baac8259-962a-4d45-a265-bf747f5f007d/fullchain.pem;

ssl_certificate_key /usr/syno/etc/certificate/ReverseProxy/baac8259-962a-4d45-a265-bf747f5f007d/privkey.pem;

location / {

    proxy_connect_timeout 60;

    proxy_read_timeout 60;

    proxy_send_timeout 60;

    proxy_intercept_errors off;

    proxy_http_version 1.1;

    proxy_set_header        X-Forwarded-Proto            \"http\";

    proxy_set_header        X-ProxyScheme            \"http\";

    proxy_set_header        Upgrade            $http_upgrade;

    proxy_set_header        Connection            $connection_upgrade;

    proxy_set_header        Host            $http_host;

    proxy_set_header        X-Real-IP            $remote_addr;

    proxy_set_header        X-Forwarded-For            $proxy_add_x_forwarded_for;

    proxy_pass http://192.168.1.4:8090;

   }
}

我只想在前端应用 SSL,在后端使用基本的 http。

此配置应该可以工作,但 websocket 网站无法打开并显示此错误:

WebSocket connection to 'wss://mydomain.com:80/' failed: Error in connection establishment: 
net::ERR_SSL_PROTOCOL_ERROR

在 web 应用程序的 javascript 文件中挖掘,我看到了这个:

window.websocket = (document.location.protocol == "https:") ? new WebSocket('wss://'+document.location.hostname+":"+window.jsonPort) : new WebSocket('ws://'+document.location.hostname+":"+window.jsonPort);

问题是我真的不明白为什么应用程序会将该方案检测为 https?由于我明确尝试使其显示为 http。

【问题讨论】:

    标签: nginx websocket reverse-proxy


    【解决方案1】:

    此问题特定于我要转发到的应用程序。我现在已经确定并纠正了该应用程序中的问题,因此问题已解决。

    【讨论】:

      猜你喜欢
      • 2017-09-27
      • 1970-01-01
      • 2020-06-06
      • 2019-06-26
      • 2019-02-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-01-01
      相关资源
      最近更新 更多