nginx "proxy_pass" cannot have URI part in location given by regular expression
2017-12-22 16:07
656 查看
PS:我是在配置nginx可以访问tomcat下面的资源文件的时候,出现了这个问题,看到这篇文章,在给nginx配置正则表达式的时候proxy_pass是不可以有uri的。
在windows中使用nginx时报错:
C:\TDDOWNLOAD\nginx-1.6.0\nginx-1.6.0>nginx.exe -s reload
nginx: [emerg] "proxy_pass" cannot have URI part in location given by regular expression, or inside named location, or inside "if" statement, or insid
e "limit_except" block in C:\TDDOWNLOAD\nginx-1.6.0\nginx-1.6.0/conf/nginx.conf:61
我的nginx配置如下:
Java代码
location ~* \.(jsp|do)$
{
index index.jsp;
proxy_pass http://localhost:8080/shop_goods;
proxy_set_header X-Real-IP $remote_addr;
}
为什么会报错呢?
因为location 使用了正则表达式(\.(jsp|do)$),而且proxy_pass中包含了URI
part(shop_goods).错误提示的意思是:
如果location包含了正则表达式,则 "proxy_pass"不能包含URI part(shop_goods).
找到原因后,修改如下:
Java代码
location ~* \.(jsp|do)$
{
index index.jsp;
proxy_pass http://localhost:8080;
proxy_set_header X-Real-IP $remote_addr;
}
注意:proxy_pass的值后面不要有斜杠,下面的是错误的:
proxy_pass http://localhost:8080/;
在windows中使用nginx时报错:
C:\TDDOWNLOAD\nginx-1.6.0\nginx-1.6.0>nginx.exe -s reload
nginx: [emerg] "proxy_pass" cannot have URI part in location given by regular expression, or inside named location, or inside "if" statement, or insid
e "limit_except" block in C:\TDDOWNLOAD\nginx-1.6.0\nginx-1.6.0/conf/nginx.conf:61
我的nginx配置如下:
Java代码
location ~* \.(jsp|do)$
{
index index.jsp;
proxy_pass http://localhost:8080/shop_goods;
proxy_set_header X-Real-IP $remote_addr;
}
为什么会报错呢?
因为location 使用了正则表达式(\.(jsp|do)$),而且proxy_pass中包含了URI
part(shop_goods).错误提示的意思是:
如果location包含了正则表达式,则 "proxy_pass"不能包含URI part(shop_goods).
找到原因后,修改如下:
Java代码
location ~* \.(jsp|do)$
{
index index.jsp;
proxy_pass http://localhost:8080;
proxy_set_header X-Real-IP $remote_addr;
}
注意:proxy_pass的值后面不要有斜杠,下面的是错误的:
proxy_pass http://localhost:8080/;
相关文章推荐
- nginx "proxy_pass" cannot have URI part in location given by regular expression
- "proxy_pass" cannot have URI part in location given by regular expression, or inside named location
- Part 83 - RegularExpression attribute in asp.net mvc
- Nginx——location常见配置指令,alias、root、proxy_pass
- nginx的proxy_pass和 location为正则表达式的问题
- 解决 "The absolute uri: xxx cannot be resolved in either web.xml or the jar files"
- nginx location if 中使用proxy_pass
- 【译】Nginx的if是如何工作的(How nginx "location if" works )By agentzh
- inline javascript cannot have the string "</script>"
- nginx: [emerg] "fastcgi_pass" directive is duplicate in /etc/nginx/sites-enabled/default:57
- Hive报错"Expression not in GROUP BY key"的解决方案
- Nginx中ip_hash负载均衡中location的proxy_pass配置与说明
- An unexpected output caused by misunderstood non-greedy mode of regular expression in PHP
- nginx反向代理proxy_pass不配置URI引起的思考
- Nginx中ip_hash负载均衡中location的proxy_pass配置与说明
- nginx中location中关于proxy_pass和rewrite的应用
- Cannot have a pipe in an action expression at column
- ASP.NET Dropdownlist 错误 "Cannot have multiple items selected in a DropDownList."
- 在Ubuntu 上编译qt4.8.6,提示“You don't seem to have 'make' or 'gmake' in your PATH. cannot proceed".”
- 运维:Nginx Location if语句中proxy_pass 不支持/context 虚拟路径的解决方案。