1. To prohibit all IP addresses from accessing the three pages a1.htm, a2.htm, and a3.htm, you can write the following in location location ~* /(a1.htm|a2.htm|a3.htm)$ { deny all; condition………; } 2. Only the specified IP is allowed to access the three pages a1.htm, a2.htm, and a3.htm. Access from other IPs is denied. location ~* /(a1.htm|a2.htm|a3.htm)$ { allow 10.0.0.2; deny all; condition………; } With this setting, only the host with IP address 10.0.0.2 can access these three pages, and other IP addresses are rejected. The same applies to other situations. For example, I need to specify that only the IP address 8.8.8.8 can access the info.php page. Then you can add the following configuration in nginx-server If the info.php page is accessed from a URL other than 8.8.8.8, a 403 error is returned. You need to add the jump address at the end, proxy_pass http://192.168.1.110:10480; otherwise there will be a 404 error. location ~/info.php$ { if ($remote_addr != '8.8.8.8' ) { return 403; } proxy_pass http://192.168.1.110:10480; } } You can also add it in the server code location ~/info.php$ { allow 8.8.8.8; deny all; condition………; } Same effect How to configure and disable IP or IP segment? The following instructions assume that the nginx directory is in /usr/local/nginx/ First, create a configuration file blockips.conf for blocking IP, then edit this file with vi blockips.conf and enter the IP to be blocked in the file. deny 1.2.3.4; deny 91.212.45.0/24; deny 91.212.65.0/24; Then save this file, open the nginx.conf file, and add the following line of configuration in the http configuration section:
Save the nginx.conf file, and then test whether the current nginx configuration file is valid:
If there is no problem with the configuration, it will output:
If there is a problem with the configuration, you need to check where the syntax problem is. If there is no problem, you need to execute the following command to let nginx reload the configuration file.
Only allow certain IPs to access the page, or prohibit certain IPs from accessing the page server_name es.mila66.com; location / { include /etx/nginx/all/ip.conf; deny all; The file format in ip.conf is:
This allows only certain IP addresses to access the page. If you want to prohibit certain IP addresses from accessing, you only need to modify it as follows: change allow to deny. server_name es.mila66.com; location / { include /etx/nginx/all/ip.conf; allow all; The file format in ip.conf is:
nginx -s reload Restart the server The above Nginx operation of restricting IP access to certain pages is all the content that the editor shares with you. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM. You may also be interested in:
|
<<: JavaScript offsetParent case study
>>: Detailed explanation of the principles and implementation methods of Mysql account management
Table of contents The creation and confusion of n...
As we all know, binlog logs are very important fo...
I won't say much nonsense, let's just loo...
Since PHP7 came out, as a fan of the latest versi...
Docker is becoming more and more mature and its f...
Table of contents Method 1: Routing meta informat...
Preface: The storage engine is the core of the da...
1. The Chinese garbled characters appear in MySQL...
For MySQL 5.5, if the character set is not set, t...
Preface This article explains how to create a dat...
Table of contents 1. What is the use of provide/i...
A situation that often occurs in a project is tha...
Enable WSL Make sure the system is Windows 10 200...
<body> <div id="root"> <...
External Access Randomly map ports Using the -P f...