i want to protect a folder of my website with a password using auth_basic. This folder contains php-scripts which should be executed if they are requested.
I tried the following:
location /admin {
auth_basic "Admin-Section";
auth_basic_user_file /myfolder/.htpasswd;
}
location ~ ^/admin/.*\.php$ {
auth_basic "Admin-Section";
auth_basic_user_file /myfolder/.htpasswd;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
I will be asked for username/password when requesting the php-scripts in that admin-folder, but the php-scripts will always be downloaded instead of executed via fastcgi.
What am i doing wrong?
EDIT: On my local machine everything works fine with this configuration. o0
EDIT: BTW, php is working outside the admin-folder with the same fastcgi-options.
EDIT: OMG! The site's config was stored at /etc/nginx/sites-available/mysite and /etc/nginx/sites-enabled/ contained a symlink to the mysite-file. Since some time changing the mysite-file had no effect. E.g. changing all locations to "deny all" had no effect. The files were sent without a problem.
So i removed the symlink and restarted the server. Then i created the symlink again, restarted the server and everything works as expected. Can someone explain the odd behaviour?
Gest regards,
Biggie