Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have set auth basic in nginx and blocked other ips like:

location / {
   auth_basic "Restricted Area";
   auth_basic_user_file .htpasswd;
   allow 127.0.0.1;
   deny all;
}

I can login using the username/password provided in .htpasswd but the error log in nginx shows errors like:

user "memcache" was not found in "/etc/nginx/.htpasswd"
no user/password was provided for basic authentication

Any suggestion why this occurs and how to get rid of it ?

share|improve this question
add comment

2 Answers

up vote 0 down vote accepted

It might not be the perfect solutions, but I had to add memcache as the new user to .htpasswd file. Now, I don't have that error of user not found. But that no user/password was provided for basic authentication is still occurring. I had explored all over and found this post from Igor Sysoev The creator of Nginx:

The HTTP Basic authentication works as following:

  • A browser requests a page without user/password.
  • A server response with 401 page, sending realm as well.
  • At this stage the 401 code appears in access_log and the message "no user/password ..." appears in error_log.
  • The browser shows a realm/login/password prompt.
  • If a user will press cancel, then the browser will show the received 401 page.
  • If the user enters login/password, then the browser repeats the request with login/password.

Then until you will exit the browser, it will send these login/password with all requests in protected hierarchy.

share|improve this answer
add comment

I did not have to add the user memcache rather I only had to install memcached and then it worked for me.

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;
        }

}
share|improve this answer
    
memcache and memcached are almost similar how they work, so, adding memcached instead shouldn't really solve the issue, given I have installed memcached too. As Igor said Nginx checks for authentication with every browser request. All browsers cache the internal auth and doesn't prompt for password everytime, so Nginx logs this as auth failure. –  Jhilke Dai Jun 12 at 7:47
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.