location ~ /tidbReport/ {
proxy_set_header Host xxxxx2.com;
proxy_pass http://xxxxx2;
}
xxxxx1.com/tidbReport/ergre → xxxxx2.com/tidbReport/ergre
原有的.com 后路由会全部传递,并且proxy_pass不支持 http://xxxxx2/xxx; 这种子路由。
location ~ /tidbReport/ {
proxy_set_header Host xxxxx2.com;
rewrite ^(.*) http://xxxxx2$1 permanant;
}
xxxxx1.com/tidbReport/ergre → xxxxx2.com/tidbReport/ergre
rewrite匹配的也是./com 后路由,rewrite最好只用于本server内重写,不要跨域,跨域时不会携带body。
rewrite中break和last区别
last:
重新将rewrite后的地址在server标签中执行
break:
将rewrite后的地址在当前location标签中执行