"proxy_pass" cannot have URI part in location given by regular expression

简介:

在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代码   收藏代码
  1. location ~* \.(jsp|do)$  
  2.       {  
  3.   
  4.             index index.jsp;  
  5.   
  6.             proxy_pass http://localhost:8080/shop_goods;  
  7.             proxy_set_header X-Real-IP $remote_addr;  
  8.         }  

 为什么会报错呢?

因为location 使用了正则表达式(\.(jsp|do)$),而且proxy_pass中包含了URI part(shop_goods).错误提示的意思是:

如果location包含了正则表达式,则 "proxy_pass"不能包含URI part(shop_goods).

找到原因后,修改如下:

Java代码   收藏代码
  1. location ~* \.(jsp|do)$  
  2.   {  
  3.   
  4.         index index.jsp;  
  5.   
  6.         proxy_pass http://localhost:8080;  
  7.         proxy_set_header X-Real-IP $remote_addr;  
  8.     }  

 注意:proxy_pass的值后面不要有斜杠,下面的是错误的:

proxy_pass http://localhost:8080/;

参考:http://huangkunlun520.blog.51cto.com/2562772/901974

相关文章
fetch上传文件报错的问题(multipart: NextPart: EOF)
技术栈 后台: gin(golang) 前端: react+antd+dva 问题 前端这边使用fetch发送http请求的时候,后端解析formData报错: multipart: NextPart: EOF 分析问题 原因是上传文件太小了Content-Length数量太小了,尝试将headers里这字段的value变大,发现实际的请求依然是较小值。
|
3月前
解决Flutter报错The named parameter |method ‘xxxx‘ isn‘t defined.
解决Flutter报错The named parameter |method ‘xxxx‘ isn‘t defined.
122 3
Warning: To load an ES module, set “type“: “module“ in the package.json or use the .mjs extension.
Warning: To load an ES module, set “type“: “module“ in the package.json or use the .mjs extension.
|
6月前
|
应用服务中间件 Linux
org.springframework.web.multipart.MultipartException: Failed to parse multipart servlet request; nes
org.springframework.web.multipart.MultipartException: Failed to parse multipart servlet request; nes
144 0
|
6月前
Angular获取Location对象,获取当前网页url、hash、hostname、href、pathname、port、protocal
Angular获取Location对象,获取当前网页url、hash、hostname、href、pathname、port、protocal
|
6月前
|
前端开发 JavaScript
Error_ Multipart_ Boundary not foun
Error_ Multipart_ Boundary not foun
101 0
|
11月前
Error: Cannot find module ‘express‘
Error: Cannot find module ‘express‘
|
JavaScript Cloud Native Go
Error: Cannot find module ‘webpack/bin/config-yargs‘ at Function.Module._resolveFilename (intern
Error: Cannot find module ‘webpack/bin/config-yargs‘ at Function.Module._resolveFilename (intern
76 0
913 error Component name “home“ should always be multi-word vuemulti-word-component-names
913 error Component name “home“ should always be multi-word vuemulti-word-component-names
100 0
|
JavaScript 前端开发 开发者
Component name “xxx“ should always be multi-word
Component name “xxx“ should always be multi-word
Component name “xxx“ should always be multi-word