Nginx forwarding based on URL parameters

Nginx forwarding based on URL parameters

Use scenarios:

The jump path needs to be dynamically configured according to the intercepted URL, which is common in accessing files and pictures with non-fixed IP addresses in the intranet.

Request address: http://11.19.1.212:82/bimg4/32.52.62.42:222/DownLoadFile?filename=LOC:12/data/20180208/15/2e0ae54dfd752210083404deed15269c_222403

The actual intranet address to be accessed: http://32.52.62.42:222/DownLoadFile?filename=LOC:12/data/20180208/15/2e0ae54dfd752210083404deed15269c_222403

nginx configuration file

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";
  }
# Here is the path after bimg4 in the request address and assigned to the forwarding address location ^ ~ / bimg4 / {
    if ($request_uri~ / bimg4 / (. * )) {
      set $bucketid $1;
    }
    proxy_pass http: //$bucketid;
  }
}

This is the end of this article about how to forward URL parameters in Nginx. For more information about Nginx URL forwarding with parameters, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • 18 Nginx proxy cache configuration tips that operators must know (which ones do you know?)
  • Summary of some common configurations and techniques of Nginx
  • Sharing tips on limiting the number of connections in nginx
  • A brief introduction to some tips for optimizing Nginx servers
  • Nginx Rewrite rules and usage introduction and skills examples
  • Implementation of nginx proxy port 80 to port 443
  • Detailed explanation of several error handling when Nginx fails to start
  • Summary of common Nginx techniques and examples

<<:  MySQL master-slave replication delay causes and solutions

>>:  js canvas implements verification code and obtains verification code function

Recommend

Class in front-end JavaScript

Table of contents 1. Class 1.1 constructor() 1.2 ...

Detailed installation process of nodejs management tool nvm

nvm nvm is responsible for managing multiple vers...

How to let https website send referrer https and http jump referrer

This article describes a proposal for a metadata ...

How to successfully retrieve VMware Esxi root password after forgetting it

Prepare a CentOS6 installation disk (any version)...

How to write beautiful HTML code

What Beautiful HTML Code Looks Like How to write ...

Detailed explanation of how to introduce custom fonts (font-face) in CSS

Why did I use this? It all started with the makin...

10 skills that make front-end developers worth millions

The skills that front-end developers need to mast...

Summary of how JS operates on pages inside and outside Iframe

Table of contents Get the content of the iframe o...

A brief talk about JavaScript variable promotion

Table of contents Preface 1. What variables are p...

JS implements jQuery's append function

Table of contents Show Me The Code Test the effec...

Vue implements bottom query function

This article example shares the specific code of ...

Implementation of Grid common layout

No gaps on both sides, gaps between each column w...

Detailed explanation of how to implement secondary cache with MySQL and Redis

Redis Introduction Redis is completely open sourc...

Detailed explanation of dynamic Christmas tree through JavaScript

Table of contents 1. Animated Christmas Tree Made...

A Brief Discussion on the Navigation Window in Iframe Web Pages

A Brief Discussion on the Navigation Window in If...