Access restriction only for people outside LAN

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

hello,

----8<-----

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…).

Yes, see satisfy_any :
http://wiki.nginx.org/NginxHttpCoreModule#satisfy_any

Cheers,

C.

On Mon, Sep 28, 2009 at 11:44:38AM +0200, Cedric J. wrote:

hello,

----8<-----

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…).

Yes, see satisfy_any :
Module ngx_http_core_module

This directive is deprecated, use

satisfy [any|all];

On Mon, Sep 28, 2009 at 11:58:21AM +0200, Tomasz P. wrote:

    if ($need_auth) {
        <auth>
    }
}

}

“satisfy any” is better;

uho, ok. maybe a note in doc would be nice.

C.

On Mon, 28 Sep 2009 14:06:57 +0400

location / {
    if ($need_auth) {
        <auth>
    }
}

}

“satisfy any” is better;

good to know, thanks!

You could try something like this.

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

server {

location / {
if ($need_auth) {

}
}
}