无法通过wss连接到服务器

时间:2016-08-25 20:36:04

标签: security ssl nginx websocket

我将以下nginx.conf文件设置为处理http和https。我目前正在使用自签名证书来测试ssl。

  server {
        listen       80;

    listen      443 ssl;

    server_name  localhost;
    ssl_certificate /etc/nginx/ssl/nginx.crt;
    ssl_certificate_key /etc/nginx/ssl/nginx.key;

    location / {
        proxy_pass http://node:8000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

    location /socketcluster/ {
        proxy_pass http://node:8000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $host;
    }

当我尝试通过localhost进行连接时。 httphttps& ws://似乎工作正常。但是,当客户端尝试通过wss://进行连接时。我得到以下错误

WebSocket connection to 'wss://localhost:80/socketcluster/' failed: Error in connection establishment: net::ERR_SSL_PROTOCOL_ERROR

我的nginx日志显示了这个 -

nginx       | 172.18.0.1 - - [25/Aug/2016:20:34:51 +0000] "\x16\x03\x01\x00\x7F\x01\x00\x00{\x03\x02\xB0\x80r\xEEH\x8C\x03\xAFFw\x9A4\xC2\x84\xB6\xD9\x9E;|\xDFbD\x1D\xF6)Ai\xB3<C\x13O\x00\x00\x10\xC0" 400 173 "-" "-"

是否还有其他内容需要添加到nginx配置文件才能让wss://正常工作?

0 个答案:

没有答案