Nginx – Configure auth_basic with Nginx and Passenger

authorizationnginxphusion-passenger

I'm trying to set up a basic authentication with Nginx.

My server configuration look like that:

server {
  listen 80;
  server_name DOMAIN;
  root /var/www/web-front-dev/current/public;
  error_log /var/log/nginx/web-front-dev-error.log;
  access_log /var/log/nginx/web-front-dev-access.log;
  passenger_enabled on;
  client_max_body_size 100M;

  location / {
    passenger_enabled on;

    auth_basic "Restricted";
    auth_basic_user_file /var/www/web-front-dev/shared/simple_authentication_user_file;
  }
}

The content of simple_authentication_user_file is simply:
a:b

After having restarted everything, I keep having an error while trying to logging to my domain (I checked that I enter 'b' correctly hmm hmm):

2011/08/10 16:10:13 [error] 26768#0: *1 user "a": password mismatch, client: IP, server: DOMAIN, request: "GET / HTTP/1.1", host: "DOMAIN"

I even put a chmod 777 to simple_authentication_user_file to see if it could be a problem without any success.

Could anyone suggest me something to check?

Best Answer

Are you trying to use a plain text password? The document states that you must use an encrypted one: http://wiki.nginx.org/HttpAuthBasicModule

Passwords must be encoded by function crypt(3).

Related Topic