VPS侦探论坛

 找回密码
 注册
查看: 5523|回复: 2

如何授权指定IP访问指定目录及目录下资源

[复制链接]
发表于 2012-6-8 17:08:36 | 显示全部楼层 |阅读模式

nginx.conf中如果只添加如下配置:

               location ~^/phpmyadmin/ {
                   allow 192.168.1.0/24;
                   deny all;
                }

来自指定ip段的主机能访问登陆页面,但点登陆后提示拒绝访问。

若改成如下配置:

               location /phpmyadmin/ {
                   allow 192.168.1.0/24;
                   deny all;
                }


               location ~ ^/phpmyadmin/.*\.php$
                {
                    allow 192.168.1.0/24;
                    deny all;
                }


则直接显示页面源代码!

===================================================================

求教:以上代码错误在哪里?如何实现允许指定IP访问特定目录 及目录下的资源(php能正常解释执行)?













===================================================================



[ 本帖最后由 secker 于 2012-6-8 17:09 编辑 ]
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2012-6-8 18:51:22 | 显示全部楼层


  1. location /phpmyadmin/ {
  2.                    allow 192.168.1.0/24;
  3.                    deny all;
  4.         location ~ .*\.(php|php5)?$
  5.                 {
  6.                         try_files $uri =404;
  7.                         fastcgi_pass  unix:/tmp/php-cgi.sock;
  8.                         fastcgi_index index.php;
  9.                         include fcgi.conf;
  10.                 }
  11. }
复制代码
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 2012-6-9 08:16:49 | 显示全部楼层

军哥牛叉
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|VPS侦探 ( 鲁ICP备16040043号-1 )

GMT+8, 2024-9-23 03:21 , Processed in 0.025852 second(s), 17 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表