nginx指定目录ip访问限制
来源:互联网 发布:知我无情有情 张南雁 编辑:程序博客网 时间:2024/05/21 06:31
前言
要实现nginx对指定目录的白名单访问,技术前提
- 正则表达式应用(自己学习即可)
- nginx的location规则匹配,参考链接:http://blog.csdn.net/zinss26914/article/details/8182625
- nginx的http access模块应用,参考链接:http://blog.csdn.net/zinss26914/article/details/8185336
实现重点
- 正则表达式中()和|的使用,()代表一个原则,|代表或
- nginx的location匹配规则中,有一条按照文件顺序进行正则匹配(ps:可以把需要匹配的目录放置在server模块开始的位置)
- allow和deny的使用
示例
目录结构
根目录/srv/
test1 / -- hello.php
test2/ -- hello.php
test3/ -- hello.php
test4/ -- {hello.php,1.php,2.php}
访问需求
对于test1,test2目录,只允许指定的192.168.1.101ip地址访问,禁止其它ip访问
对于其他目录的php程序,所有ip地址均可以访问
实现的nginx配置文件
#指定目录实行白名单访问机制location ~ ^/(test1|test2)/ {allow 192.168.1.101;deny all;root /srv/; fastcgi_paramHTTPS on; include /etc/nginx/fastcgi_params; fastcgi_pass php5_fpm;} # proxy the PHP scripts to fpm location ~ \.php$ {root /srv/; fastcgi_paramHTTPS on; include /etc/nginx/fastcgi_params; fastcgi_pass php5_fpm; }
- nginx指定目录ip访问限制
- Nginx限制ip访问
- nginx限制IP访问
- nginx限制IP访问
- Nginx限制目录访问
- nginx限制ip访问 nginx访问权限
- nginx限制ip访问权限
- Nginx限制ip多次访问
- .htaccess ip 目录访问限制 apache ip限制目录访问 网站目录IP限制访问
- 触发器限制指定IP访问oracle数据库
- nginx apache限制ip并发访问 限制ip连接
- nginx中针对目录进行IP限制
- linux iptables IP限制访问 指定IP访问
- linux iptables IP限制访问 指定IP访问
- nginx配置二:限制来源ip访问
- nginx限制ip访问,进行认证
- nginx添加ip访问频率限制
- nginx添加ip访问频率限制
- 提高软件质量实践―― Amazon 篇
- 用mysql触发器自动更新memcache
- MFC中设置对话框颜色、添加背景图片、添加音乐的方法
- 设备坐标和逻辑坐标
- 停止Java线程,小心interrupt()方法
- nginx指定目录ip访问限制
- MFC静态文本框透明
- Properties转换成有序Map
- 关于Android 启用新输入法时的系统设置
- 阶乘——高精度求法
- 从RAC恢复到单实例数据库操作步骤
- 深入浅出理解索引结构
- 项目开发和管理需要弄清楚的6个问题
- 基于ACE的线程池学习与实现(二)——ACE_Message_Block与ACE_Condition