如何使用proxy_pass nginx服务器添加postfix url

时间:2016-02-26 07:51:36

标签: nginx nginx-location winginx

我是nginx服务器的新手。我想发送

的请求

http://localhost:81/app/get/all

http://localhost:9000/abc/get/all

我使用了位置正则表达式。但它没有用,任何人都可以帮助我。

我已将服务器添加为:

 upstream dev {
        server 127.0.0.1:9000;
    }
server {
        rewrite_log on;
        listen [::]:81;
        server_name localhost;

        location / {
            root   path;
        index  index.html index.htm;
    }
    location ~ ^/app/.+ {
        proxy_pass  http://dev;
            proxy_set_header  Host $http_host;
    }
}

请帮帮我。

1 个答案:

答案 0 :(得分:0)

如果您可以将位置指定为前缀位置,则可以使用proxy_pass指令修改URI:

location /app/ {
    proxy_pass http://dev/abc/;
    ...
}

有关详细信息,请参阅this document

或者,您可以使用break修饰符重写URI:

location ~ ^/app/. {
    rewrite ^/app(.*)$ /abc$1 break;
    proxy_pass http://dev;
    ...
}

有关详细信息,请参阅this document

相关问题