通过域连接到套接字时,返回404

时间:2019-10-22 05:49:41

标签: nginx websocket

对ws:// domain / constructor / websocket请求的响应返回404 我的nginx配置:

/etc/nginx.conf

http {

    ....

    map $http_upgrade $connection_upgrade {
        default upgrade;
        ''      close;
    }

    upstream websocket {
      server 127.0.0.1:8080;
    }

    ....

    include /etc/nginx/sites-enabled/*;
}

/ etc / nginx / sites-enabled / site

server {
    listen  80;
    proxy_set_header        Host       $host;
    proxy_set_header        X-Real-IP  $remote_addr;
    proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header        X-Forwarded-Proto $scheme;
    proxy_redirect          http:// $scheme://;

    ....

    location /constructor/websocket {
        proxy_pass http://websocket;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

如果我通过本地IP地址,一切正常。

当我尝试使用域进行连接时,它不起作用

0 个答案:

没有答案