<p class="MsoNormal">Ha!</p>
<p class="MsoNormal">What a simple solution. </p>
<p class="MsoNormal">Thanks a lot!</p>
<p class="MsoNormal">-Quintin</p><br><div class="gmail_quote">On Wed, Feb 15, 2012 at 2:39 PM, Maxim Dounin <span dir="ltr"><<a href="mailto:mdounin@mdounin.ru">mdounin@mdounin.ru</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello!<br>
<div class="im"><br>
On Wed, Feb 15, 2012 at 10:03:13AM +0530, Quintin Par wrote:<br>
<br>
> Hi all,<br>
><br>
> I have a location directive with basic auth in it.<br>
><br>
> location / {<br>
><br>
> auth_basic "Admin Login";<br>
><br>
> auth_basic_user_file /etc/nginx/.htpasswd;<br>
><br>
> How do I specify a rule such that the basic auth is applied only to<br>
> external IPs and not to 127.0.0.x, 192.0.x & 10.0.x?<br>
<br>
</div>Use "satisfy any", see<br>
<a href="http://www.nginx.org/en/docs/http/ngx_http_core_module.html#satisfy" target="_blank">http://www.nginx.org/en/docs/http/ngx_http_core_module.html#satisfy</a><br>
<br>
location / {<br>
satisfy any;<br>
<div class="im"><br>
auth_basic "Admin Login";<br>
auth_basic_user_file /etc/nginx/.htpasswd;<br>
<br>
</div> allow <a href="http://127.0.0.0/24" target="_blank">127.0.0.0/24</a>;<br>
allow <a href="http://192.0.0.0/16" target="_blank">192.0.0.0/16</a>;<br>
allow <a href="http://10.0.0.0/16" target="_blank">10.0.0.0/16</a>;<br>
deny all;<br>
}<br>
<br>
Just a side note: the "192.0.x" should probably be "192.168.x"<br>
instead, but you should get the idea anyway.<br>
<span class="HOEnZb"><font color="#888888"><br>
Maxim Dounin<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
_______________________________________________<br>
nginx mailing list<br>
<a href="mailto:nginx@nginx.org">nginx@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx" target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx</a><br>
</div></div></blockquote></div><br>