技术解析

Nginx 反向代理配置的疑惑
0
2021-05-25 15:46:58
idczone

现有服务器有两台: 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,而后面的目录没有代理到,求解

这个看着并不需要正则匹配,用`location /g2 `这样试试?

源目录保持过去? 那就没必要 写 2 个 location 了啊

502 Bad Gateway 还是这个错误

更换 tengine 后解决

数据地带为您的网站提供全球顶级IDC资源
在线咨询
专属客服