WD1X.COM - 问答一下,轻松解决,电脑应用解决专家
主板显卡CPU内存显示器
硬盘维修显卡维修显示器维修
注册表系统命令DOS命令Win8
存储光存储鼠标键盘
内存维修打印机维修
WinXPWin7Win11Linux
硬件综合机箱电源散热器手机数码
主板维修CPU维修键盘鼠标维修
Word教程Excel教程PowerPointWPS
网络工具系统工具图像工具
数据库javascript服务器
PHP教程CSS教程XML教程

nginx中针对目录进行IP限制

更新时间:2013-06-25 12:41 作者:佚名点击:

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;
                      }
 
顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------
你可能感兴趣的内容