• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Question Nginx behaving strangely with auth_basic

Dirk

Basic Pleskian
I have the following line in nginx. conf:
location ^~ /internal/ {auth_basic "Restricted"; auth_basic_user_file /var/www/. htpasswd; }

This works well, but the following problem occurs. If I'm in the internal area and now access a php file in the directory, it won't be executed but downloaded. As soon as I comment out the above line, everything works fine again.
Now, if I skip the ^ so that the line looks like this:
location ~ /internal/ {auth_basic "Restricted"; auth_basic_user_file /var/www/. htpasswd; }
Then the php will be executed again, but you can now access individual files directly in the protected directory - so you can't access www.domain.de/internal without password, but you can access www.domain.de/internal/bild1.jpg

Does anyone have an idea how I can protect the entire directory and its contents and still the php runs normally?
 
Back
Top