服务器技术

 首页 > 服务器技术 > nginx > nginx禁止某个IP访问站点的设置方法_nginx_自学ph

nginx禁止某个IP访问站点的设置方法_nginx_自学ph

分享到:
【字体:
导读:
          近期发现博客遭到某些人的恶意灌水,频繁地利用发帖机器人发表评论,给博客的管理带来诸多不便,搜索了一下资料,可以利用nginx的ngx_http_access_module 模块设置允许/禁止哪些ip或ip段...

首先建立下面的配置文件放在nginx的conf目录下面,命名为blocksip.conf:

deny 95.105.25.181;

保存一下。

在nginx的配置文件nginx.conf中加入:include blocksip.conf;

重启一下nginx的服务:/usr/local/nginx/sbin/nginx -s reload 就可以生效了。

blocksip.conf:的格式还有许多种,可以配置只允许的IP访问或者IP段访问:

deny IP;

allow IP;

# block all ips
deny all;
# allow all ips
allow all;

其中网段的写法是这样的:192.168.1.0/24这样的形式。

这样就可以达到目的了。
分享到:
nginx could not build the server_names...
nginx “nginx could not build the server_names_hash”解决方法 给一个服务器下增加了一些站点别名,差不多有20多个。 重启nginx时候,提示: could not build the server_names_hash, you should increase server_names_hash_bucket_size: 32 解决方法: 在配置文件的http{}段增加一行配置 server_names_hash_bucket_siz...
nginx的FastDFS分布式存储模块测试方法_n...
再回过头来看FastDFS更新很快,还看到fastdfs-nginx-module_v1.01.tar.gz nginx模块,所以今天在一台测试机上测试了·测试几天看稳定不稳定,在考虑换掉浪费资源的 lustre ! 环境: storage1:192.168.6.100 storage2:192.168.6.101 tracker:192.168.6.102 1. 在每个机器上,下载安装 FastDFS nginx $> wget http://...
  •         php迷,一个php技术的分享社区,专属您自己的技术摘抄本、收藏夹。
  • 在这里……