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

CocosCreator classic entry project flappybird

Table of contents Development Environment Game en...

Analysis of the methods of visual structure layout design for children's websites

1. Warm and gentle Related address: http://www.web...

Vue simple implementation of turntable lottery

This article shares the specific code of Vue to s...

Uninstalling MySQL database under Linux

How to uninstall MySQL database under Linux? The ...

Setting up a proxy server using nginx

Nginx can use its reverse proxy function to imple...

Version numbers in css and js links in HTML (refresh cache)

background Search the keyword .htaccess cache in ...

Detailed explanation of the order of JS object traversal

Some of you may have heard that the order of trav...

Summary of 76 Experience Points of User Experience

Classification of website experience 1. Sensory e...

Use tomcat to set shared lib to share the same jar

As more and more projects are deployed, more and ...

Vue implements tree table through element tree control

Table of contents Implementation effect diagram I...

Script to quickly list all host names (computer names) in the LAN under Linux

Recently, I have a need to list all host names in...

MySQL data type selection principles

Table of contents Small but beautiful Keep it sim...

MySQL paging analysis principle and efficiency improvement

MySQL paging analysis principle and efficiency im...

Linux kernel device driver virtual file system notes

/******************** * Virtual File System VFS *...