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

发布时间:2020-09-20 11:18:08 作者:牧之山野
来源:脚本之家 阅读:806

使用场景:

需要根据截取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带参数转发内容请搜索亿速云以前的文章或继续浏览下面的相关文章希望大家以后多多支持亿速云!

推荐阅读:
  1. nginx怎样实现反向代理?
  2. nginx的基本使用和反向代理,地址重写问题

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

nginx url 参数转发

上一篇:js实现简单模态框实例

下一篇:C#简单获取全屏中鼠标焦点位置坐标的方法示例

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》