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

Nginx 反向代理配置的疑惑

  •  
  •   popphen · 2016-09-06 21:47:11 +08:00 · 2549 次点击
    这是一个创建于 2789 天前的主题,其中的信息可能已经有所发展或是发生改变。

    现有服务器有两台: a.https://172.16.100.143:8443/t1 a.https://172.16.100.143:8443/g2

    b.https://172.16.100.143:8443/t1 b.https://172.16.100.143:8443/g2

    upstream t {
    server 172.16.100.143:8443 weight=1;
    server 172.16.100.144:8443 weight=2;

    location ~ ^/t1(/?)(.*){ proxy_pass https://t proxy_read_timeout 30;
    proxy_set_header Host $host:$server_port; 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; root html; index index.html index.htm; client_max_body_size 20m; }

        location ~ ^/g2(/?)(.*){
            proxy_pass https://t;
            proxy_read_timeout 30;            
            proxy_set_header Host $host:$server_port;
            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;
            root   html;
            index  index.html index.htm;
            client_max_body_size    20m;
        }
        
        如今效果似乎只代理到了 8443,而后面的目录没有代理到,求解
    
    4 条回复    2016-09-07 12:17:00 +08:00
    Senorsen
        1
    Senorsen  
       2016-09-06 22:03:34 +08:00 via Android
    这个看着并不需要正则匹配,用`location /g2 `这样试试?
    akira
        2
    akira  
       2016-09-06 22:04:43 +08:00
    源目录保持过去? 那就没必要 写 2 个 location 了啊
    popphen
        3
    popphen  
    OP
       2016-09-06 22:17:05 +08:00
    @Senorsen 502 Bad Gateway 还是这个错误
    popphen
        4
    popphen  
    OP
       2016-09-07 12:17:00 +08:00 via iPhone
    更换 tengine 后解决
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2609 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 01:48 · PVG 09:48 · LAX 18:48 · JFK 21:48
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.