<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>basic_auth and php-fpm</title>
<description>Hello there,

I'm trying to protect one sub directory with basic_auth and I having some troubles.
My config for virtualhost looks like this:

root /var/www/site.ru/;
index index.php index.html index.htm

location ~ .php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/site.ru$fastcgi_script_name;
include fastcgi_params;
gzip_static on;
}

location /somewhere/ {
auth_basic &amp;quot;Restricted area&amp;quot;;
auth_basic_user_file /var/www/site.ru/somewhere/.htpasswd;
}

What I'm trying to do is to force user enter his credentials when he's trying to access /somewhere. If you're knocking to http://site.ru/somewhere, authorization works like a charm, but when I tried to access some particular script (http://site.ru/somewhere/index.php, for instance), authorization isn't working (login prompt just went missing).

My guess is that first general location is overriding second's options, but I failed to fix this.
I'm using vanilla nginx 1.0.11 and php5-fpm from Dotdeb.
Any help would be very appreciated. Thanks in advance.</description><link>http://forum.nginx.org/read.php?11,221820,221820#msg-221820</link><lastBuildDate>Tue, 18 Jun 2013 19:44:12 -0400</lastBuildDate>
<generator>Phorum 5.2.16</generator>
<item>
<guid>http://forum.nginx.org/read.php?11,221820,221820#msg-221820</guid>
<title>basic_auth and php-fpm</title><link>http://forum.nginx.org/read.php?11,221820,221820#msg-221820</link><description><![CDATA[Hello there,<br /><br />I'm trying to protect one sub directory with basic_auth and I having some troubles.<br />My config for virtualhost looks like this:<br /><br />root /var/www/site.ru/;<br />index index.php index.html index.htm<br /><br />location ~ .php$ {<br />fastcgi_pass 127.0.0.1:9000;<br />fastcgi_index index.php;<br />fastcgi_param SCRIPT_FILENAME /var/www/site.ru$fastcgi_script_name;<br />include fastcgi_params;<br />gzip_static on;<br />}<br /><br />location /somewhere/ {<br />auth_basic &quot;Restricted area&quot;;<br />auth_basic_user_file /var/www/site.ru/somewhere/.htpasswd;<br />}<br /><br />What I'm trying to do is to force user enter his credentials when he's trying to access /somewhere. If you're knocking to http://site.ru/somewhere, authorization works like a charm, but when I tried to access some particular script (http://site.ru/somewhere/index.php, for instance), authorization isn't working (login prompt just went missing).<br /><br />My guess is that first general location is overriding second's options, but I failed to fix this.<br />I'm using vanilla nginx 1.0.11 and php5-fpm from Dotdeb.<br />Any help would be very appreciated. Thanks in advance.]]></description>
<dc:creator>ru_maniac</dc:creator>
<category>How to...</category><pubDate>Tue, 31 Jan 2012 02:53:46 -0500</pubDate></item>
</channel>
</rss>