Nginx

推荐列表 站点导航

当前位置:首页 > 服务器技术 > Nginx >

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

来源:网络整理  作者:wy  发布时间:2020-12-23 11:24
这篇文章主要介绍了Nginx 根据URL带的参数转发的实现,文中通过示例代码介绍的非常详细,对大家的学习或者工作具...

需要根据截取URL动态配置跳转路径,常见于访问内网不固定ip地址的文件图片,

请求地址::82/bimg4/32.52.62.42:222/DownLoadFile?filename=LOC:12/data/20180208/15/2e0ae54dfd752210083404deed15269c_222403

实际需要访问的内网地址::222/DownLoadFile?filename=LOC:12/data/20180208/15/2e0ae54dfd752210083404deed15269c_222403

nginx配置文件

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

 

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";

  }

 

1

2

3

4

5

6

7

8

 

# 此处为截取请求地址中bimg4之后的路径,并赋给转发地址

  location ^ ~ / bimg4 / {

    if ($request_uri~ / bimg4 / (. * )) {

      set $bucketid $1;

    }

    proxy_pass http: //$bucketid;

  }

}

 

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

原文链接:https://blog.csdn.net/gaoshanqr/article/details/79303135

相关热词:

本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供用于网络技术学习参考,学习中请遵循相关法律法规!

本文地址: https://v30.fanwenzhu.com/server/nginx/8111.shtml

最新文章
并且强制用 HTTPS 访问 fa 并且强制用 HTTPS 访问 fa

时间:2021-01-14

可以控制访问量 可以控制访问量

时间:2021-01-14

(通配符在前) ③server (通配符在前) ③server

时间:2021-01-14

Nginx环境下WordPress的多站点 Nginx环境下WordPress的多站点

时间:2021-01-05

nginx keepalive的具体使用 nginx keepalive的具体使用

时间:2021-01-05

Nginx的信号控制 Nginx的信号控制

时间:2021-01-05

win10上安装nginx的方法步骤 win10上安装nginx的方法步骤

时间:2020-12-29

linux下 nginx监控问题 linux下 nginx监控问题

时间:2020-12-29

Copyright © www.juheyunku.com      关于 | 合作 | 声明 | 联系 | 更新 | 地图 | Tags

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

2020-12-23 编辑:wy

需要根据截取URL动态配置跳转路径,常见于访问内网不固定ip地址的文件图片,

请求地址::82/bimg4/32.52.62.42:222/DownLoadFile?filename=LOC:12/data/20180208/15/2e0ae54dfd752210083404deed15269c_222403

实际需要访问的内网地址::222/DownLoadFile?filename=LOC:12/data/20180208/15/2e0ae54dfd752210083404deed15269c_222403

nginx配置文件

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

 

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";

  }

 

1

2

3

4

5

6

7

8

 

# 此处为截取请求地址中bimg4之后的路径,并赋给转发地址

  location ^ ~ / bimg4 / {

    if ($request_uri~ / bimg4 / (. * )) {

      set $bucketid $1;

    }

    proxy_pass http: //$bucketid;

  }

}

 

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

原文链接:https://blog.csdn.net/gaoshanqr/article/details/79303135

本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供学习参考!
本文地址为 https://v30.fanwenzhu.com/server/nginx/8111.shtml

相关文章

风云图片

推荐阅读

返回Nginx频道首页