You are here

Drupal网站admin管理界面限制内部IP访问

g089h515r806 的头像
Submitted by g089h515r806 on 星期二, 2025-07-08 08:54

部分单位出于安全的考虑,管理页面只让内网访问,特别是护网阶段。我们的Drupal站点,通常使用Nginx,这里介绍一下通过nginx的配置文件,实现这个功能

       location /admin {

                     # 第一步:允许内网网段

                  allow 10.0.0.0/24;

                     allow 10.8.6.0/24;

                     # 第二步:拒绝所有其他IP

                     deny all;

         try_files $uri /index.php?$query_string; # For Drupal >= 7

                    

       }

AI给出的allow 10.0.0.0/24;,但是并不匹配所有的内网地址。

改成allow 10.8.6.0/24;,这是所在单位的内网地址。0/24表示后一位匹配所有。

 

加上这个, try_files $uri /index.php?$query_string;

或者加上:proxy_pass http://mysite;

 

 经过测试,初步达到了目的。


论坛:

Drupal版本: