Nginx ban IP, allowing only domain names

Nginx modify profile
1, profile open
generally Ngnix configuration file in the / usr / local / nginx / conf / directory, using the following command to open the profile:

vim /usr/local/nginx/conf/nginx.conf

2, modify the configuration file
, add the following code to the server:

if ($host ~ "\d+\.\d+\.\d+\.\d") {
    return 404;
}

Nginx ban IP, allowing only domain names

~ Followed along with the regular expression matching is IP, if matched to the IP, it returns 404 to prohibit their access.

3, restart Nginx service
using the following instruction restart Nginx services:

service nginx reload

Guess you like

Origin www.cnblogs.com/enumx/p/12316149.html