nginx重写

希望访问http://status.sinson.org/test/dashboard/index时nginx代理到http://center.szuswzx.com/center/dashboard/index

设置如下:

location /test/{

if ($request_uri ~* "status\.sinson\.org/test/(.*)"){
    proxy_pass `http://center.szuswzx.com/center/$1`;
}

}

但是实际上报的error是找不到test/dashboard/index.html

明显没有做到代理,求问原因?怎么样设置才能获取到dashboard/index 然后转发到http://center.szuswzx.com/center/$1

阅读 2.1k
2 个回答

把这条location放到最前试试

$request_uri这个变量的值不包含域名

location ~ ^/test/(.*) {
    proxy_pass http://center.szuswzx.com/center/$1;
}
推荐问题