How to add Nginx proxy configuration to allow only internal IP access

How to add Nginx proxy configuration to allow only internal IP access
location / {
index index.jsp;
proxy_next_upstream http_500 http_502 http_503 http_504 error timeout invalid_header;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
deny 192.168.1.1;
allow 127.0.0.0/24;
allow 123.56.0.0/16;
allow 172.16.0.0/16;
allow 10.170.0.0/16;
deny all;
}

The above is my location configuration list

Note:

1. You must add an IP address when denying , otherwise it will jump directly to 403 without further execution; if the 403 default page is under the same domain name, it will cause an infinite loop of access;

2. Allowed IP segments

Arrange from the smallest to the largest segment allowed to be accessed, such as: 127.0.0.0/24

The following can be: 10.170.0.0/16

24 represents the subnet mask: 255.255.255.0

16 represents the subnet mask: 255.255.0.0

8 represents the subnet mask: 255.0.0.0

3. deny all; ending

Indicates that all other parameters except the above allow are prohibited

The above is all the knowledge points introduced this time. Thank you for your learning and support for 123WORDPRESS.COM.

You may also be interested in:
  • Implementation of debugging code through nginx reverse proxy
  • How to use Nginx to proxy multiple application sites in Docker
  • Nginx forward and reverse proxy and load balancing functions configuration code example
  • How to implement cross-domain API proxy forwarding through Nginx proxy forwarding configuration
  • Detailed explanation of how to add Nginx proxy using Go
  • Implementation of removing prefix from Nginx proxy pass configuration
  • 18 Nginx proxy cache configuration tips that operators must know (which ones do you know?)
  • Difference and principle analysis of Nginx forward and reverse proxy

<<:  Detailed explanation of rpm installation in mysql

>>:  Detailed explanation of the execution process of JavaScript engine V8

Recommend

Detailed explanation of log processing of Docker containers

Docker has many log plug-ins. The default is to u...

js to realize simple shopping cart function

This article example shares the specific code of ...

JavaScript canvas realizes colorful sun halo effect

This article example shares the specific code of ...

How to make your own native JavaScript router

Table of contents Preface Introduction JavaScript...

Vue implements seamless scrolling of lists

This article example shares the specific code of ...

How to mark the source and origin of CSS3 citations

I am almost going moldy staying at home due to th...

How to modify the scroll bar style in Vue

Table of contents First of all, you need to know ...

Analysis and solution of the problem that MySQL instance cannot be started

Table of contents Preface Scenario Analysis Summa...

Implementation of CSS sticky footer classic layout

What is a sticky footer layout? Our common web pa...

Detailed explanation of where the images pulled by docker are stored

The commands pulled by docker are stored in the /...

Detailed explanation of the difference between flex and inline-flex in CSS

inline-flex is the same as inline-block. It is a ...

Basic operations of mysql learning notes table

Create Table create table table name create table...

Install two MySQL5.6.35 databases under win10

Record the installation of two MySQL5.6.35 databa...