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 tutorial on installation and configuration of MySql 5.7.17 winx64

1. Download the software 1. Go to the MySQL offic...

Detailed explanation of linux nslookup command usage

[Who is nslookup?] 】 The nslookup command is a ve...

A brief talk about MySQL pivot tables

I have a product parts table like this: part part...

What are the new features of Apache Spark 2.4, which will be released in 2018?

This article is from the Apache Spark Meetup held...

10 ways to view compressed file contents in Linux (summary)

Generally speaking, when we view the contents of ...

Complete steps of centos cloning linux virtual machine sharing

Preface When a Linux is fully set up, you can use...

Instructions for using JSON operation functions in Mysql5.7

Preface JSON is a lightweight data exchange forma...

Native js implementation of slider interval component

This article example shares the specific code of ...

How to build a React project with Vite

Table of contents Preface Create a Vite project R...

Various front-end printing methods of web: CSS controls web page printing style

CSS controls the printing style of web pages : Use...

Detailed example of deploying Nginx+Apache dynamic and static separation

Introduction to Nginx dynamic and static separati...

Mysql 8.0.18 hash join test (recommended)

Hash Join Hash Join does not require any indexes ...

DHTML objects (common properties of various HTML objects)

!DOCTYPE Specifies the Document Type Definition (...

How to delete a MySQL table

It is very easy to delete a table in MySQL, but y...