鍍金池/ 問答/Linux/ nginx重寫

nginx重寫

希望訪問http://status.sinson.org/test/dashboard/index時nginx代理到http://center.szuswzx.com/center/dashboard/index

設(shè)置如下:

location /test/{

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

}

但是實際上報的error是找不到test/dashboard/index.html

明顯沒有做到代理,求問原因?怎么樣設(shè)置才能獲取到dashboard/index 然后轉(zhuǎn)發(fā)到http://center.szuswzx.com/center/$1

回答
編輯回答
壞脾滊

$request_uri這個變量的值不包含域名

location ~ ^/test/(.*) {
    proxy_pass http://center.szuswzx.com/center/$1;
}
2017年10月23日 22:10
編輯回答
瘋浪

把這條location放到最前試試

2018年1月18日 08:49