title: nginx: auth_basic and php
body: <p>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.</p>
  
  <p>I tried the following:</p>
  
  <pre><code>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;
   }
  </code></pre>
  
  <p>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.</p>
  
  <p>What am i doing wrong?</p>
  
  <p>EDIT: On my local machine everything works fine with this configuration. o0<br />
  EDIT: BTW, php is working outside the admin-folder with the same fastcgi-options.<br />
  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.<br />
  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?</p>
  
  <p>Gest regards,<br />
  Biggie</p>