I recently deployed my first nginx setup and everything works really nice, except the location parsing is driving me nuts. I have a simple php fastcgi setup like this:
location ~ \.php {
if (!-e $request_filename) {
return 404;
}
include /etc/nginx/fastcgi.conf;
keepalive_timeout 0;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
}
Now i want to secure some locations with basic auth like this:
location /madmin {
auth_basic "Restricted";
auth_basic_user_file /var/www/localhost/admincp/.htpasswd;
}
Witht his setup, nginx asks for a password when going to /madmin, but won't ask at /madmin/foo.php. If i change the auth location to something like "location ~ ^/madmin" then nginx serves php file for download ...
isn't it possible to configure multiple locations in nginx? if not, what's the workaround here?
Thanks for your help.