如何在 nginx 配置中设置位置指令前缀和后缀?
How to set location directive prefix and postfix in nginx configuration?
我想使用一个位置指令 nginx 作为
/auth/
示例:-
location = /auth/v1/registration
{
proxy_pass http://backend1/auth/v1/registration;
}
在这个例子中,我希望如果我在 /auth/ 之前和 /auth/ 之后提供任何东西,默认情况下它仅匹配 auth
location = *****/auth/*******
{
proxy_pass http://backend1/auth/v1/registration;
}
我可以用*****替换什么
提前谢谢你...
The regular expressions used by nginx are compatible with those used
by the Perl programming language (PCRE).
试一试:
location ~* ^.*/auth/.*$ { ... }
测试:
# pcretest
PCRE version 8.39 2016-06-14
re> ~^.*/auth/.*$~i
data> /some/auth/text
0: /some/auth/text
data> /some/text
No match
data> /auth/text
0: /auth/text
data> /some/auth/
0: /some/auth/
data> /some/auth2
No match
我想使用一个位置指令 nginx 作为
/auth/
示例:-
location = /auth/v1/registration
{
proxy_pass http://backend1/auth/v1/registration;
}
在这个例子中,我希望如果我在 /auth/ 之前和 /auth/ 之后提供任何东西,默认情况下它仅匹配 auth
location = *****/auth/*******
{
proxy_pass http://backend1/auth/v1/registration;
}
我可以用*****替换什么 提前谢谢你...
The regular expressions used by nginx are compatible with those used by the Perl programming language (PCRE).
试一试:
location ~* ^.*/auth/.*$ { ... }
测试:
# pcretest
PCRE version 8.39 2016-06-14
re> ~^.*/auth/.*$~i
data> /some/auth/text
0: /some/auth/text
data> /some/text
No match
data> /auth/text
0: /auth/text
data> /some/auth/
0: /some/auth/
data> /some/auth2
No match