Basic Auth only for external IPs and not localhost or LAN networks
Quintin Par
quintinpar at gmail.com
Wed Feb 15 10:16:27 UTC 2012
Ha!
What a simple solution.
Thanks a lot!
-Quintin
On Wed, Feb 15, 2012 at 2:39 PM, Maxim Dounin <mdounin at mdounin.ru> wrote:
> Hello!
>
> On Wed, Feb 15, 2012 at 10:03:13AM +0530, Quintin Par wrote:
>
> > Hi all,
> >
> > I have a location directive with basic auth in it.
> >
> > location / {
> >
> > auth_basic "Admin Login";
> >
> > auth_basic_user_file /etc/nginx/.htpasswd;
> >
> > How do I specify a rule such that the basic auth is applied only to
> > external IPs and not to 127.0.0.x, 192.0.x & 10.0.x?
>
> Use "satisfy any", see
> http://www.nginx.org/en/docs/http/ngx_http_core_module.html#satisfy
>
> location / {
> satisfy any;
>
> auth_basic "Admin Login";
> auth_basic_user_file /etc/nginx/.htpasswd;
>
> allow 127.0.0.0/24;
> allow 192.0.0.0/16;
> allow 10.0.0.0/16;
> deny all;
> }
>
> Just a side note: the "192.0.x" should probably be "192.168.x"
> instead, but you should get the idea anyway.
>
> Maxim Dounin
>
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20120215/9d7de3a5/attachment.html>
More information about the nginx
mailing list