主要是為了防止蜘蛛采集或別人攻擊撵溃,具體步驟如下:
在nginx配置目錄下,新建deny.conf文件缘挑,如下所示:
[root@mail conf.d]# pwd
/etc/nginx/conf.d
[root@mail conf.d]# ll
-rw-r--r--. 1 root root?? 19? 2月 22 15:28 deny.conf
[root@mail conf.d]# cat deny.conf
deny 123.7.84.160;
其中:
deny 123.7.84.160; #屏蔽123.7.84.160
deny 123.7.84.0/24; #屏蔽123.7.84.1 ~ 123.7.84.255整個網(wǎng)段IP
再讓nginx.conf加載此配置文件语淘,如下所示(nginx1.x默認會加載/etc/nginx/conf.d/下的所有配置文件):
[root@mail nginx]# pwd
/etc/nginx
[root@mail nginx]# ll
總用量 36
drwxr-xr-x. 2 root root 4096? 2月 22 15:28 conf.d
-rw-r--r--. 1 root root? 964 12月 12 00:57 fastcgi_params
-rw-r--r--. 1 root root 2837 12月 12 00:57 koi-utf
-rw-r--r--. 1 root root 2223 12月 12 00:57 koi-win
-rw-r--r--. 1 root root 3463 12月 12 00:57 mime.types
-rw-r--r--. 1 root root 1052? 2月? 6 15:22 nginx.conf
-rw-r--r--. 1 root root? 596 12月 12 00:57 scgi_params
-rw-r--r--. 1 root root? 623 12月 12 00:57 uwsgi_params
-rw-r--r--. 1 root root 3610 12月 12 00:57 win-utf
[root@mail nginx]# cat nginx.conf
..........(以上省略)
http {
include/etc/nginx/conf.d/*.conf;
..........(以下省略)
}