我正在尝试密码保护我的Nginx支持的网站上的目录,其中包含PHPMyAdmin,MemcacheMyAdmin和更多管理实用程序.
此目录位于我的站点的根目录中:
domain.com/control/
我服务器上的绝对路径是:
/home/deployer/sites/domain.com/control/
我使用以下命令在目录中创建了一个.htpasswd文件:
htpasswd -c /home/deployer/sites/domain.com/control/.htpasswd admin
在Nginx中此域的.conf文件中,我使用以下位置块来要求身份验证.
location /control {
auth_basic "Restricted Area: Control";
auth_basic_user_file /home/deployer/sites/domain.com/control/.htpasswd;
}
当进入受密码保护的目录时,系统会提示我输入用户名和密码.我输入我之前创建的凭据,然后我会看到错误403禁止页面.
访问日志显示我正在访问登录提示,然后以“admin”用户身份登录:
64.123.456.225 - - [12/May/2013:17:30:48 +0000] "GET /control HTTP/1.1" 401 597 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.31 (KHTML,like Gecko) Chrome/26.0.1410.64 Safari/537.31"
64.123.456.225 - admin [12/May/2013:17:30:48 +0000] "GET /control HTTP/1.1" 301 185 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.31 (KHTML,like Gecko) Chrome/26.0.1410.64 Safari/537.31"
64.123.456.225 - admin [12/May/2013:17:30:59 +0000] "GET /control/memcache/ HTTP/1.1" 403 199 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.31 (KHTML,like Gecko) Chrome/26.0.1410.64 Safari/537.31"
2013/05/12 17:31:01 [error] 30462#0: *1 directory index of "/home/deployer/sites/domain.com/control/memcache/" is forbidden,client: 64.123.456.225,server: domain.com,request: "GET /control/memcache/ HTTP/1.1",host: "domain.com"
2013/05/12 17:31:09 [error] 30462#0: *1 directory index of "/home/deployer/sites/domain.com/control/memcache/" is forbidden,host: "domain.com"
如果我删除该站点的Nginx .conf的Auth块,我就可以正常访问该页面了.
谢谢你的帮助!
最佳答案
原文链接:https://www.f2er.com/nginx/434383.html