• Please be aware: Kaspersky Anti-Virus has been deprecated
    With the upgrade to Plesk Obsidian 18.0.64, "Kaspersky Anti-Virus for Servers" will be automatically removed from the servers it is installed on. We recommend that you migrate to Sophos Anti-Virus for Servers.
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

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