Access restriction only for people outside LAN

Tomasz Pajor nikon at puffy.pl
Mon Sep 28 13:58:21 MSD 2009


You could try something like this.

geo $need_auth {
    default 1;
    192.168.1.0/24 0;
}

server {
    ...
    location / {
        if ($need_auth) {
            <auth>
        }
    }
}
> Hi all,
>
> I have a service which should be protected using Basic Authentication,
> but this authentication should be enabled only for people who connect
> to my service from "the outside of my LAN". Other people (inside LAN)
> should not have any authentication.
>
> Is this possible? How to do that? I couldn't figure out how to use
> combination of allow/deny with basic authentication for certain
> location (maybe this is wrong way...).
>
> Cheers,
> Kamil
>
>   






More information about the nginx mailing list