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

阅读 2k
2 个回答

把这条location放到最前试试

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

location ~ ^/test/(.*) {
    proxy_pass http://center.szuswzx.com/center/$1;
}
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题