启动nginx时会报以下错误,原因是在给nginx配置正则表达式的时候proxy_pass是不可以有uri的。
nginx: [emerg] "proxy_pass" cannot have URI part in location given by regular expression, or inside named location, or inside "if" statement, or insid
我的nginx配置如下:
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).
找到原因后,修改如下:
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/; 这里8080后面的/不能有。