参考SO: nginx ‘proxy_pass’ cannot have URI part in location?
使用下面的配置会出现上面的问题
location ~ ^/web/(project1|project2|project3)/$ {
proxy_pass https://example.com/h5/;
}
原因:
nginx cannot process your desired URI part in the proxy_pass directive
because you’re within a named location (hence the error message). This
is because nginx is built in a modular fashion and each configuration
block is read in various stages by the various modules. So just
remember that you cannot have a URI within your proxy_pass directive
in the following cases:Regular Expression Locations Named Locations if Blocks
解决方案
location ~ ^/web/(project1|project2|project3)/$ {
rewrite ^/web/(.*) /h5/$1;
proxy_pass https://example.com;
}