nginx访问控制配置
2015-06-08 11:32
429 查看
限制只让某个ip访问 allow 219.232.244.234; deny all; 禁止某个IP或者IP段访问站点的设置方法 首先建立下面的配置文件放在nginx的conf目录下面,命名为deny.ip cat deny.ipdeny 192.168.1.11;deny 192.168.1.123;deny 10.0.1.0/24;在nginx的配置文件nginx.conf中加入:include deny.ip;重启一下nginx的服务:/usr/local/nginx/sbin/nginx reload 就可以生效了。 deny.ip 的格式中也可以用deny all; 如果你想实现这样的应用,除了几个IP外,其他全部拒绝,那需要你在deny.ip 中这样写allow 1.1.1.1;allow 1.1.1.2;deny all; 有时候会根据目录来限制php解析:location ~ .*(diy|template|attachments|forumdata|attachment|image)/.*\.php${ deny all;} 使用 user_agent 控制客户端访问 location / { if($http_user_agent~'bingbot/2.0|MJ12bot/v1.4.2|Spider/3.0|YoudaoBot|Tomato|Gecko/20100315'){ return 403;}}
相关文章推荐
- Ruby中require、load、include、extend的区别介绍
- CSS注释、命名、继承性、样式排序等CSS技巧的小结
- Powershell Profiles配置文件的存放位置介绍
- vbscript include的办法实现代码第1/2页
- PowerShell入门教程之创建和使用配置文件实例
- SERV-U 的配置文件详解
- PHP脚本中include文件出错解决方法
- Flex include和import ActionScript代码
- php.ini 配置文件的深入解析
- set_include_path在win和linux下的区别
- php include加载文件两种方式效率比较
- PHP配置文件php.ini中打开错误报告的设置方法
- How to Auto Include a Javascript File
- 浅谈ASP.NET的include的使用方法
- 深入理解JavaScript系列(2) 揭秘命名函数表达式
- java/jsp中 中文问题详解
- C#中读取App.config配置文件代码实例
- php相对当前文件include其它文件的方法
- JSP计数器的制作
- c++实现逐行读取配置文件写入内存的示例