我正在用nginx运行CentOS 6。它目前正在运行完美,我试图密码保护我的管理目录。我可以成功登录。但是,当我尝试查看目录中的主索引页(index.php)时,我得到了403 Forbbiden。Nginx密码保护403禁止
2013/04/18 02:10:17 [error] 17166#0: *24 directory index of "/usr/share/ngin/html /somedir/" is forbidden, client: XXX, server: mysite.com, request: "GET /somedir/ HTTP/1.1", host: "mysite.com"
我对“.htpasswd”文件进行了双重检查。它属于使用chmod 640的“root:root”。我也尝试将owner船舶设置为“nginx:nginx”,错误仍然存在。
这是我如何得到htpasswd的工作:
location ~ ^/([^/]*)/(.*) {
if (-f $document_root/$1/.htpasswd) {
error_page 599 = @auth;
return 599;
}
}
location @auth {
auth_basic "Password-protected";
auth_basic_user_file $document_root/$1/.htpasswd;
}