网站首页
手机版

nginx中针对目录进行IP限制 nginx限制访问ip

更新时间:2024-06-02 00:06:50作者:未知

nginx中针对目录进行IP限制 nginx限制访问ip

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;
}

本文标签: 用户  优先级  正则  

为您推荐

nginx中对指定的IP不使用密码对区域外IP使用密码

nginx中对指定的IP不使用密码对区域外IP使用密码 ## example admin site server { server_name $HOSTNAME

2024-06-02 00:06

如何让Nginx支持中文文件名(如何让nginx支持中文文件名改为英文)

如何让Nginx支持中文文件名 首先得让你的系统有中语语言包: 设置前可以执行:locale 看一下,如果显示是en_US.UTF-8,即是正常,不用按下面的步

2024-06-02 00:06

nginx中针对目录进行IP限制 nginx限制访问ip

nginx中针对目录进行IP限制 nginx phpmyadmin 针对内网ip用户开放、外网ip用户关闭(在前面的配置中,location ~ ^/目录/使用

2024-06-02 00:06

抖音位置可以随便设置在哪里吗(抖音的位置可以随便设置吗)

最佳答案抖音位置可以随便设置在哪里。1、在抖音发布视频页面里找到“添加位置”功能。2、点击打开添加位置页面,页面最上方有个“搜索栏”。3、在搜索栏里输入一个想要展示的某个位置,然后即可搜索出很多详细地址供你选择。4、选择一个位置后直接返回到发布页面,即可看到所在位置信息已经更改完成。

2024-06-01 10:37

快手有赞地址在哪修改(快手有赞地址怎么修改)

最佳答案打开快手,点击左上角的按钮。在此界面点击“设置”。选择快手小店。进入店铺页面,点击我的地址。在对象中,单击编辑。修改后,点击“保存并使用”即可。

2024-06-01 02:57

nginx 301 302重定向跳转配置

nginx 301 302重定向跳转配置 首先看一个完整代码示例,关于nginx 301 302跳转的。 301跳转设置: server { listen 80

2024-06-01 00:09