V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
NGINX
NGINX Trac
3rd Party Modules
Security Advisories
CHANGES
OpenResty
ngx_lua
Tengine
在线学习资源
NGINX 开发从入门到精通
NGINX Modules
ngx_echo
guangzhouwuyanzu
V2EX  ›  NGINX

nginx proxy_pass 端口问题

  •  
  •   guangzhouwuyanzu · 2018-11-09 13:42:00 +08:00 · 2637 次点击
    这是一个创建于 1967 天前的主题,其中的信息可能已经有所发展或是发生改变。
    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; 是可以的。

    我哪里姿势不对了= =

    1 条回复    2018-11-09 15:12:42 +08:00
    d0m2o08
        1
    d0m2o08  
       2018-11-09 15:12:42 +08:00
    proxy_pass http://backend;
    proxy_set_header Host $host:$server_port;
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5395 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 686ms · UTC 07:50 · PVG 15:50 · LAX 00:50 · JFK 03:50
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.