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

Docker installation of MySQL (8 and 5.7)

This article will introduce how to use Docker to ...

The whole process record of Vue export Excel function

Table of contents 1. Front-end leading process: 2...

Talk about how to identify HTML escape characters through code

Occasionally you'll see characters such as &#...

Introduction to 10 online development tools for web design

1. Online Text Generator BlindTextGenerator: For ...

MySQL joint index effective conditions and index invalid conditions

Table of contents 1. Conditions for joint index f...

Nginx load balancing algorithm and failover analysis

Overview Nginx load balancing provides upstream s...

Writing a shell script in Ubuntu to start automatically at boot (recommended)

The purpose of writing scripts is to avoid having...

Summary of H5 wake-up APP implementation methods and points for attention

Table of contents Preface Jump to APP method URL ...

Share some tips on using JavaScript operators

Table of contents 1. Optional chaining operator [...

React+axios implements github search user function (sample code)

load Request Success Request failed Click cmd and...

Nginx dynamically forwards to upstream according to the path in the URL

In Nginx, there are some advanced scenarios where...

jQuery implements ad display and hide animation

We often see ads appear after a few seconds and t...

Solution to changing the data storage location of the database in MySQL 5.7

As the data stored in the MySQL database graduall...

JavaScript to achieve simple drag effect

This article shares the specific code of JavaScri...