<div dir="ltr"><div><div><div><font color="#333399"><font>I found inspiration <a href="http://serverfault.com/questions/119076/how-to-use-fastcgi-globally-and-basic-auth-in-sublocations-in-nginx">here</a>.<br></font></font></div>

<div><font color="#333399"><font><br>I then tried to solve my problem with:<br><br></font></font></div><font color="#333399"><font><font>location /thisfile.php {<br></font></font></font></div><div><font color="#333399"><font><font><font>    auth_basic off;<br>

<br></font></font></font></font></div><div><font color="#333399"><font><font><font># Start</font> of *exact* copy<br></font></font></font></div><font color="#333399"><font><font><font>    location ~ \.php$ {<br><font>    </font></font></font></font></font><font color="#333399"><font><font><font><font><font color="#333399"><font><font><font><font>    FastCGI stuff here...</font></font></font></font></font></font></font></font></font></font><br>

<font>    }</font><br></div><font color="#333399"><font><font><font><font># End of *exact* copy</font><br></font></font></font></font><div><div><font color="#333399"><font><font><font>}<br><br><font>location ~ \.php$ {<br>

    FastCGI stuff here...<br>}<br><br></font></font></font></font></font></div><div><font color="#333399"><font><font><font><font><font>I don't like this solution because it makes me copying my FastCGI work.<br></font></font></font></font></font></font></div>

<div><font color="#333399"><font><font><font><font><font><font>W<font>hat if one day I am to modify it? <font>I<font>'ll probably forget there are 2 places to check...</font></font></font></font></font></font></font></font></font></font><br>

<br></div><div><font color="#333399"><font><font><font><font><font><font>But it seems to work.</font><br><br></font></font></font></font></font></font></div><div><font color="#333399"><font><font><font><font><font><font>A<font>n</font>y better idea?</font><br>

<br></font></font></font></font></font></font></div><div><font color="#333399"><font><font><font><font><font><font>A<font>n</font>other poin<font>t</font></font>:<br></font></font></font></font></font></font></div><div><font color="#333399"><font><font><font><font><font><font>If I set 'location = /thisfile.php'</font> rather than 'location /thisfile.php', Nginx insults me with 'nginx: [emerg] location "\.php$" cannot be inside the exact location "/thisfile.php"' again. Bug or feature?<br>

</font></font></font></font></font></font></div></div></div><div class="gmail_extra"><br clear="all"><div><font size="1"><span style="color:rgb(102,102,102)">---<br></span><b><span style="color:rgb(102,102,102)">B. R.</span></b><span style="color:rgb(102,102,102)"></span></font></div>


<br><br><div class="gmail_quote">On Thu, Dec 27, 2012 at 8:36 AM, B.R. <span dir="ltr"><<a href="mailto:reallfqq-nginx@yahoo.fr" target="_blank">reallfqq-nginx@yahoo.fr</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div dir="ltr"><div><div><div><div><font color="#333399"><font>Hello,<br><br></font></font></div><font color="#333399"><font><font>I am using the auth_basic directive to restrict access to a whole ser<font>ver (auth_basic server-wide set, not in any particular location).<br>


</font></font></font></font></div><font color="#333399"><font><font><font><font>Since I </font>am using php, I am also usi<font>ng:<br><br></font></font></font></font></font></div><font color="#333399"><font><font><font><font><font>location ~ \.php$ {<br>


</font></font></font></font></font></font></div><font color="#333399"><font><font><font><font><font><font>    FastC<font>GI</font> stuff</font> here...<br></font></font></font></font></font></font><div><font color="#333399"><font><font><font><font><font><font>}</font><br>


<br></font></font></font></font></font></font></div><div><font color="#333399"><font><font><font><font><font><font>to forward</font> my request to the PHP application.<br><br></font></font></font></font></font></font></div>


<div><font color="#333399"><font><font><font><font><font><font>Now, I would like to re<font>move the auth_basic authentication for a very unique and specific locatio<font>n: <font>thisfile.php<br><br></font></font></font></font></font></font></font></font></font></font></div>


<div><font color="#333399"><font><font><font><font><font><font><font><font><font><font>I first tried</font>:<br></font></font></font></font></font></font></font></font></font></font><br clear="all"><font color="#333399"><font><font><font><font><font>location ~ \.php$ {<br>


</font></font></font></font></font></font></div><div><font color="#333399"><font><font><font><font><font><font>    location = /thisfile.php {<br></font></font></font></font></font></font></font></div><div><font color="#333399"><font><font><font><font><font><font><font>        auth_basic off;<br>


</font></font></font></font></font></font></font></font></div><div><font color="#333399"><font><font><font><font><font><font><font><font>    }</font><br></font></font></font></font></font></font></font></font></div><div>

<font color="#333399"><font><font><font><font><font><font>    FastC<font>GI</font> stuff</font> here...<br>
</font></font></font></font></font></font><font color="#333399"><font><font><font><font><font><font>}</font><br><br></font></font></font></font></font></font></div><div><font color="#333399"><font><font><font><font><font><font>but Nginx said<font>:<br>


nginx: [emerg] location "/thisfile.php" is outside location "\.php$" in .../nginx/conf.d/<font>mystupid</font>.conf:6<font>9</font><br>nginx: configuration file .../nginx/nginx.conf test failed</font></font><br>


<br></font></font></font></font></font></font></div><div><font color="#333399"><font><font><font><font><font><font>I then tried:<br></font></font></font></font></font></font></font><br><font color="#333399"><font><font><font><font><font><font><font color="#333399"><font><font><font><font><font>location ~ \.php$ {<br>


</font></font></font></font></font></font></font></font></font></font></font></font></font><div><font color="#333399"><font><font><font><font><font><font>    location ~ ^/thisfile.php$ {<br></font></font></font></font></font></font></font></div>


<div><font color="#333399"><font><font><font><font><font><font><font>        auth_basic off;<br></font></font></font></font></font></font></font></font></div><div><font color="#333399"><font><font><font><font><font><font><font><font>    }</font><br>


</font></font></font></font></font></font></font></font></div><div><font color="#333399"><font><font><font><font><font><font>    FastC<font>GI</font> stuff</font> here...<br></font></font></font></font></font></font><font color="#333399"><font><font><font><font><font><font>}</font><br>


<br></font></font></font></font></font></font></div><font color="#333399"><font><font><font><font><font><font>But of course now the Fast<font>CGI part does not server the request and the PHP file is sent for download...</font><br>


<br></font></font></font></font></font></font></font></div><div><font color="#333399"><font><font><font><font><font><font><font>What king of clean solution do I have?<br></font></font></font></font></font></font></font></font></div>


<div><font color="#333399"><font><font><font><font><font><font><font><font>Am I forced to place the auth_basic in <font>all my <font>'location' blocks but one, which would be for 'thisfile.php<font>'?<br>

<br>
</font></font></font></font></font></font></font></font></font></font></font></font></div><div><font color="#333399"><font><font><font><font><font><font><font><font><font><font><font><font>Thanks,</font></font></font></font></font></font></font></font></font></font></font></font></font><br clear="all">


<div><font size="1"><span style="color:rgb(102,102,102)">---<br></span><b><span style="color:rgb(102,102,102)">B. R.</span></b><span style="color:rgb(102,102,102)"></span></font></div>
</div></div>
</blockquote></div><br></div>