最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
nginx中针对目录进行IP限制
时间:2022-06-30 18:55:58 编辑:袖梨 来源:一聚教程网
nginx phpmyadmin 针对内网ip用户开放、外网ip用户关闭(在前面的配置中,location ~ ^/目录/使用正则, 优先级高于location /的配置,所以nginx无法对首页进行解析)
代码如下 | 复制代码 |
server { listen 80; server_name example.com; access_log logs/access.log main; location / { root html; index index.php index.html index.htm; } location ~ ^/phpmyadmin/ { allow 192.168.1.0/24; deny all; location ~ .*.(php|php5)?$ { root /var/mailapp/nginx/html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi_params; } } location ~ .*.(php|php5)?$ { root /opt/nginx/html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi_params; } } |
我们也可以这样配置
代码如下 | 复制代码 |
server { listen 80; server_name example.com; access_log logs/access.log main; location / { root html; index index.php index.html index.htm; } location ~ ^/download/ { allow 192.168.1.0/24; deny all; index index.php index.do index.html index.htm; location ~ .*.(php|php5)?$ { root /var/mailapp/nginx/html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi_params; } } location ~ .*.(php|php5)?$ { root /opt/nginx/html; astcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi_params; } |
限制指定的连接只允许 某个指定的IP 能行访问
相关文章
- 碧蓝航线的里雅斯特期待的便当时间皮肤有什么 04-30
- 明日之后踏浪逐星服装展示攻略 04-30
- 深空之眼幽月塞勒涅刻印搭配核心思路 04-30
- 明日之后红杉茶会护卫队首领BOSS有哪些 04-30
- CF手游段位奖励汇总攻略 04-30
- 无期迷途5-13怎么走攻略 04-30