我一个 tomcat 有多个应用,比如我访问 localhost ,我想让 nginx 转发给 localhost:8080/hello
我在配置文件里设置
location ~ .*\.(jsp|do)$ {
proxy_pass http://localhost:8080/hello/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
启动的时候会提示
"proxy_pass" cannot have URI part in location given by regular expression,
or inside named location, or inside "if" statement,
or inside "limit_except" block in /etc/nginx/conf.d/default.conf:7
查了查,说是 proxy_pass 后面不能有斜杠,可是都没具体的解决办法,特来 v 站请教
1
Infernalzero 2016-12-23 22:52:28 +08:00
错误提示已经这么明显了,不是不能有斜杠,是不能有 URI ,这里只能指定 host ,要转发到固定 URI pattern 下用 rewrite
|
2
binbinyouliiii OP @Infernalzero 今天第一次用,然而 rewrite 什么的根本没有接触过,本想着先跑通再说
|