nginx 多个location指向同一个代理

nginx 多个location指向同一个代理配置示例:


upstream targetpowermonitor{
    server 192.168.140.45:80;
}
server {
    location /powermonitor/ {
            proxy_pass http://targetpowermonitor/;
        }
    location ~ ^/(ves|vesapp|static/plugins) {
            proxy_pass http://targetpowermonitor;
        }
}

本质上是location正则匹配规则的活用

    location ~ ^/(路径1|路径2|路径3|路径4|路径5) {
        proxy_pass  跳转的地址;
        proxy_set_header $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header x-tif-uid $http_x_tif_uid;
        proxy_connect_timeout 600;
        proxy_read_timeout 600;
        proxy_send_timeout 600;
        proxy_ignore_client_abort on;
        proxy_next_upstream timeout;
    }

你可能感兴趣的:(nginx 多个location指向同一个代理)