“proxy_pass” cannot have URI part in location given by regular expression

后端 未结 1 732
长情又很酷
长情又很酷 2020-12-05 19:13

I\'ve developed a URL shortening web application.

It consists of two separate docker containers: one containing the backend REST api and another containing the fron

相关标签:
1条回答
  • 2020-12-05 20:05

    If you use a URI with a proxy_pass statement within a regular expression location, you need to build the entire URI using one or more variables. See this document for details.

    So the alternatives are to (1), capture the URI from the location expression and add it to the proxy_pass statement. For example:

    location ~ ^/([A-Za-z0-9]+) {
        proxy_pass http://api/urlshortener/v1/$1;
    }
    

    Or (2), use proxy_pass without a URI part, and construct the desired URI using a rewrite...break. For example:

    location ~ ^/([A-Za-z0-9]+) {
        rewrite ^/([A-Za-z0-9]+) /urlshortener/v1/$1 break; 
        proxy_pass http://api;
    }
    

    See this document for details.

    0 讨论(0)
提交回复
热议问题