<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
<font face="Helvetica, Arial, sans-serif">If it helps, here's a section
of my config that is working for auth on one directory only,<br>
server {<br>
server_name blah;<br>
root /var/www/mysite;<br>
...some rewrites not relevant...<br>
location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; include
fastcgi_params; }<br>
location ~ ^/free/admin { <br>
auth_basic "Restricted"; <br>
auth_basic_user_file /var/www/mysite/free/admin/.htpasswd; <br>
}<br>
}<br>
</font><br>
David wrote:
<blockquote cite="mid:loom.20080907T131315-961@post.gmane.org"
type="cite">
<pre wrap="">Hello,
I am having a hard time trying to password protect a directory containing
PHP files.
Whenever I access <a class="moz-txt-link-abbreviated" href="http://www.domain.com/forums/admin/">www.domain.com/forums/admin/</a> I get a 404 error.
I have tried setting a fastcgi_param SCRIPT_FILENAME in my forums/admin
location section and that doesn't work either. I have also been moving around
location sections incase there was a correct processing order that I
was missing out on but I couldn't get it to change anything.
Any help would be greatly appreciated.
This is my domain.conf
server {
listen 192.168.30.10;
server_name <a class="moz-txt-link-abbreviated" href="http://www.domain.com">www.domain.com</a>;
access_log /var/log/nginx/domain.com.access.log main;
root /home/user/public_html;
index index.php index.html index.htm;
include /usr/local/nginx/fastcgi_params;
location / {
}
location ^~ /forums/admin {
auth_basic "Authorization Required";
auth_basic_user_file /home/user/not_web_accessible/.htpasswd;
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_intercept_errors on;
}
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_intercept_errors on;
fastcgi_param SCRIPT_FILENAME
/home/user/public_html$fastcgi_script_name;
}
}
</pre>
</blockquote>
</body>
</html>