Simple http authentication not working

Below is my config. The folder /site/private is supposed to show the
usual HTTP authentication box, but the php files from that folder just
start downloading in clear text. What am I doing wrong? The path of the
passwd file is correct.

Thanks for any pointers!

location / {

  location

~.*.(gif|jpg|png|ico|swf|rss|xml|htm|txt|js|css|gz|doc|xls|pdf)$ {
expires max;
try_files $uri @backend;
log_not_found off;
}

  location /site/private {
    auth_basic              "Restricted";
    auth_basic_user_file

/home/MYDOMAIN/.htpasswds/public_html/www/private/passwd;
}

  proxy_pass http://MY.IP.IS.HERE:8081;
  include proxy.inc;
}  #-- End of root location

location @backend {
  internal;
  proxy_pass http://MY.IP.IS.HERE:8081;
  include proxy.inc;
}

Posted at Nginx Forum:

Hello!

On Sun, Jun 05, 2011 at 04:22:46PM -0400, pk899 wrote:

Below is my config. The folder /site/private is supposed to show the
usual HTTP authentication box, but the php files from that folder just
start downloading in clear text. What am I doing wrong? The path of the
passwd file is correct.

It’s not clear what is the problem you are complaining about.

  1. PHP files in clear text? You don’t have any processing for php
    defined in location /site/private. Default behaviour is to serve
    anything as static. So php files being served as static is
    expected result of your config.

  2. No HTTP authentication box? It should appear only once per
    browser start (or may not appear at all if you’re brave enough to
    save your password in browser). Check data of the wire or nginx
    logs (access log should be enough) to see if authentication really
    happens.

Maxim D.

On 5 Jun 2011 21h22 WEST, [email protected] wrote:

location
~.*.(gif|jpg|png|ico|swf|rss|xml|htm|txt|js|css|gz|doc|xls|pdf)$ {
expires max; try_files $uri @backend; log_not_found off; }

location /site/private {
auth_basic “Restricted”;
auth_basic_user_file
/home/MYDOMAIN/.htpasswds/public_html/www/private/passwd;
}

Right now the /site/private location is for handling static files
only. You’ve not defined any handler for scripts or any type of
upstream. So that’s what you should get. Download the file when you
request it.

— appa