nginx proxy_pass 端口问题

2018-11-09 13:42:00 +08:00
 guangzhouwuyanzu
server
    {
        listen 443 ssl http2;
        server_name host.com;
        ssl on;
        ssl_certificate /usr/local/nginx/conf/host.com_crt/host.com_bundle.crt;
        ssl_certificate_key /usr/local/nginx/conf/host.com_crt/host.com.key;
        index index.html;
        root /var/www/default;
        include enable-php.conf;
        location /web {
            # proxy_pass http://127.0.0.1:10121;
            proxy_pass http://127.0.0.1:$server_port;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
        }
        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
        {
            expires      30d;
        }
        location ~ .*\.(js|css)?$
        {
            expires      12h;
        }
        location ~ /.well-known {
            allow all;
        }
        location ~ /\.
        {
            deny all;
        }
        #access_log  /var/wwwlogs/host.com.log;
    }

配置如上 wss://host.com/web:10121

并没有转发到 proxy_pass http://127.0.0.1:10121;

$server_port 好像没起作用

写死 proxy_pass http://127.0.0.1:10121; 是可以的。

我哪里姿势不对了= =

2661 次点击
所在节点    NGINX
1 条回复
d0m2o08
2018-11-09 15:12:42 +08:00
proxy_pass http://backend;
proxy_set_header Host $host:$server_port;

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/506103

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX