Nginx 根據(jù)URL帶的參數(shù)轉(zhuǎn)發(fā)的實(shí)現(xiàn)
使用場(chǎng)景:
需要根據(jù)截取URL動(dòng)態(tài)配置跳轉(zhuǎn)路徑,常見(jiàn)于訪問(wèn)內(nèi)網(wǎng)不固定ip地址的文件圖片,
請(qǐng)求地址:http://11.19.1.212:82/bimg4/32.52.62.42:222/DownLoadFile?filename=LOC:12/data/20180208/15/2e0ae54dfd752210083404deed15269c_222403
實(shí)際需要訪問(wèn)的內(nèi)網(wǎng)地址:http://32.52.62.42:222/DownLoadFile?filename=LOC:12/data/20180208/15/2e0ae54dfd752210083404deed15269c_222403
nginx配置文件
server {
listen 83;
server_name localhost;
index index.html index.htm;
root D: /workspace-xxxx/xxx_Web;
error_page 500 502 503 504 / 50x.html;
location = /50x.html {
root html;
}
location ^~ /xxx/ {
proxy_pass http: //192.168.60.36:8090/xxxx/;
proxy_redirect default;
proxy_set_header Host $host;
proxy_set_header X - Real - IP $remote_addr;
proxy_set_header X - Forwarded - Host $host;
proxy_set_header X - Forwarded - Server $host;
proxy_set_header X - Forwarded - For $proxy_add_x_forwarded_for;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
# 此處為截取請(qǐng)求地址中bimg4之后的路徑,并賦給轉(zhuǎn)發(fā)地址
location ^ ~ / bimg4 / {
if ($request_uri~ / bimg4 / (. * )) {
set $bucketid $1;
}
proxy_pass http: //$bucketid;
}
}
到此這篇關(guān)于Nginx 根據(jù)URL帶的參數(shù)轉(zhuǎn)發(fā)的實(shí)現(xiàn)的文章就介紹到這了,更多相關(guān)Nginx URL帶參數(shù)轉(zhuǎn)發(fā)內(nèi)容請(qǐng)搜索本站以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持本站!
版權(quán)聲明:本站文章來(lái)源標(biāo)注為YINGSOO的內(nèi)容版權(quán)均為本站所有,歡迎引用、轉(zhuǎn)載,請(qǐng)保持原文完整并注明來(lái)源及原文鏈接。禁止復(fù)制或仿造本網(wǎng)站,禁止在非maisonbaluchon.cn所屬的服務(wù)器上建立鏡像,否則將依法追究法律責(zé)任。本站部分內(nèi)容來(lái)源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來(lái),僅供學(xué)習(xí)參考,不代表本站立場(chǎng),如有內(nèi)容涉嫌侵權(quán),請(qǐng)聯(lián)系alex-e#qq.com處理。
關(guān)注官方微信