当前位置:   首页安装配置转发地址:Nginx 根据URL带的参数转发的实现

转发地址:Nginx 根据URL带的参数转发的实现

发布日期:2021-06-03 18:05 | 文章来源:源码之家

使用场景:

需要根据截取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 {
  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";
  }
# 此处为截取请求地址中bimg4之后的路径,并赋给转发地址
  location ^ ~ / bimg4 / {
    if ($request_uri~ / bimg4 / (. * )) {
      set $bucketid $1;
    }
    proxy_pass http: //$bucketid;
  }
}

到此这篇关于Nginx 根据URL带的参数转发的实现的文章就介绍到这了,更多相关Nginx URL带参数转发内容请搜索本站以前的文章或继续浏览下面的相关文章希望大家以后多多支持本站!

联系我们
关于使用场景和技术架构的更多咨询,请联系我们的销售和技术支持团队。
Yingsoo Host

在线
客服

在线客服:7*24小时在线

客服
热线

400-630-3752
7*24小时客服服务热线

关注
微信

关注官方微信
顶部