我已经在Nginx中设置了auth的基本function,并且阻止了其他的ips:
location / { auth_basic "Restricted Area"; auth_basic_user_file .htpasswd; allow 127.0.0.1; deny all; }
我可以使用.htpasswd提供的username/passwordlogin,但nginx中的错误日志显示如下错误:
user "memcache" was not found in "/etc/nginx/.htpasswd" no user/password was provided for basic authentication
任何build议,为什么会发生这种情况,如何摆脱它?
这可能不是完美的解决scheme,但是我必须将memcache作为新用户添加到.htpasswd文件中。 现在,我user not found错误。 但是no user/password was provided for basic authentication仍在发生。 我已经探索了所有,并从Igor Sysoev发现这个postNginx的创造者:
HTTP基本身份validation的工作如下:
- 浏览器请求没有用户/密码的页面。
- 服务器响应401页面,发送领域以及。
- 在这个阶段,401代码出现在access_log中,error_log中显示“no user / password …”消息。
- 浏览器显示领域/login/密码提示。
- 如果用户按取消,浏览器将显示收到的401页面。
- 如果用户inputlogin名/密码,则浏览器用login名/密码重复该请求。
然后,直到您退出浏览器,它将发送这些login名/密码与保护层次结构中的所有请求。
我不必添加用户memcache,而只需要安装memcached,然后它为我工作。
server { # Change these settings to match your machine listen 80; server_name yourdomain.com; satisfy any; allow 127.0.0.1; deny all; # Restrict Access auth_basic "Restricted"; auth_basic_user_file /var/www/.htpasswd; access_log /var/log/nginx/domain_access.log; error_log /var/log/nginx/domain_error.log; # deny access to .htaccess files location ~ /\.ht { deny all; } }