本文共 575 字,大约阅读时间需要 1 分钟。
我尝试使用if , location 处理部分URL, 然后放行到 proxy_pass 反复尝试都提示下面的错误
nginx: [emerg] "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/info.mydomain.com.conf:112?
nginx: configuration file /etc/nginx/nginx.conf test failed
最后发现使用$request_uri变量可以解决上述问题.
if ( $request_uri ~ "^/\w+\.xml$") {
proxy_pass http://www.mydomain.com/xml$request_uri;
break;
}
if ( $request_uri ~ "^/public/datas/\w+\.xml$") {
proxy_pass http://www.mydomain.com/$request_uri;
break;
}
转载地址:http://gznkx.baihongyu.com/