Nginx 根据URL带的参数转发的实现
使用场景:
需要根据截取URL动态配置跳转路径,常见于访问内网不固定ip地址的文件图片,
请求地址:http://11.19.1.212:82/bimg4/32.52.62.42:222/DownLoadFile?filename=LOC:12/data/20180208/15/2e0ae54dfd752210083404deed15269c_222403
实际需要访问的内网地址:http://32.52.62.42:222/DownLoadFile?filename=LOC:12/data/20180208/15/2e0ae54dfd752210083404deed15269c_222403
nginx配置文件
server{
listen83;
server_namelocalhost;
indexindex.htmlindex.htm;
rootD:/workspace-xxxx/xxx_Web;
error_page500502503504/50x.html;
location=/50x.html{
roothtml;
}
location^~/xxx/{
proxy_passhttp://192.168.60.36:8090/xxxx/;
proxy_redirectdefault;
proxy_set_headerHost$host;
proxy_set_headerX-Real-IP$remote_addr;
proxy_set_headerX-Forwarded-Host$host;
proxy_set_headerX-Forwarded-Server$host;
proxy_set_headerX-Forwarded-For$proxy_add_x_forwarded_for;
proxy_set_headerUpgrade$http_upgrade;
proxy_set_headerConnection"Upgrade";
}
#此处为截取请求地址中bimg4之后的路径,并赋给转发地址
location^~/bimg4/{
if($request_uri~/bimg4/(.*)){
set$bucketid$1;
}
proxy_passhttp://$bucketid;
}
}
到此这篇关于Nginx根据URL带的参数转发的实现的文章就介绍到这了,更多相关NginxURL带参数转发内容请搜索毛票票以前的文章或继续浏览下面的相关文章希望大家以后多多支持毛票票!
声明:本文内容来源于网络,版权归原作者所有,内容由互联网用户自发贡献自行上传,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任。如果您发现有涉嫌版权的内容,欢迎发送邮件至:czq8825#qq.com(发邮件时,请将#更换为@)进行举报,并提供相关证据,一经查实,本站将立刻删除涉嫌侵权内容。