|
主要是为了防止蜘蛛采集或别人攻击,具体步骤如下:
在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整个网段IP
再让nginx.conf加载此配置文件,如下所示(nginx1.x默认会加载/etc/nginx/conf.d/下的所有配置文件):- root@mail nginx]# pwd
- 02 /etc/nginx
- 03 [root@mail nginx]# ll
- 04 总用量 36
- 05 drwxr-xr-x. 2 root root 4096 2月 22 15:28 conf.d
- 06 -rw-r--r--. 1 root root 964 12月 12 00:57 fastcgi_params
- 07 -rw-r--r--. 1 root root 2837 12月 12 00:57 koi-utf
- 08 -rw-r--r--. 1 root root 2223 12月 12 00:57 koi-win
- 09 -rw-r--r--. 1 root root 3463 12月 12 00:57 mime.types
- 10 -rw-r--r--. 1 root root 1052 2月 6 15:22 nginx.conf
- 11 -rw-r--r--. 1 root root 596 12月 12 00:57 scgi_params
- 12 -rw-r--r--. 1 root root 623 12月 12 00:57 uwsgi_params
- 13 -rw-r--r--. 1 root root 3610 12月 12 00:57 win-utf
- 14 [root@mail nginx]# cat nginx.conf
- 15 ..........(以上省略)
- 16 http {
- 17 include /etc/nginx/conf.d/*.conf;
- 18 ..........(以下省略)
- 19 }
复制代码 本文摘自:http://www.juziku.com/sunlightcs/wiki/6440.htm
|
|