nginx怎样开启目录访问权限
展开全部
nginx中针对目录进行IP限制 ,这里以phpmyadmin目录只能让内网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;
}
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;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |