Hello there,
I'm trying to protect one sub directory with basic_auth and I having some troubles.
My config for virtualhost looks like this:
root /var/www/site.ru/;
index index.php index.html index.htm
location ~ .php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/site.ru$fastcgi_script_name;
include fastcgi_params;
gzip_static on;
}
location /somewhere/ {
auth_basic "Restricted area";
auth_basic_user_file /var/www/site.ru/somewhere/.htpasswd;
}
What I'm trying to do is to force user enter his credentials when he's trying to access /somewhere. If you're knocking to http://site.ru/somewhere, authorization works like a charm, but when I tried to access some particular script (http://site.ru/somewhere/index.php, for instance), authorization isn't working (login prompt just went missing).
My guess is that first general location is overriding second's options, but I failed to fix this.
I'm using vanilla nginx 1.0.11 and php5-fpm from Dotdeb.
Any help would be very appreciated. Thanks in advance.
Edited 1 time(s). Last edit at 01/31/2012 02:55AM by ru_maniac.