Your ads will be inserted here by

Easy Plugin for AdSense.

Please go to the plugin admin page to
Paste your ad code OR
Suppress this ad slot.

Restricting Access using allow deny with satisfy Any.

Access can be allowed or denied based on the IP address of a client or by using HTTP basic authentication.

To allow or deny access from a certain set of addresses, or all addresses, use the allow and deny directives:

location / {
allow 192.168.1.1/24;
allow 127.0.0.1;
deny 192.168.1.2;
deny all;
}

Restricting access with allow deny can be complemented with use of http://nginx.org/en/docs/http/ngx_http_auth_basic_module.html

Your ads will be inserted here by

Easy Plugin for AdSense.

Please go to the plugin admin page to
Paste your ad code OR
Suppress this ad slot.

which allows to use either IP based restriction or User password based authentication. This is one of the key feature in Apache and majority of we want to have simillar use case senario:

location / {
auth_basic "closed site";
auth_basic_user_file conf/htpasswd;
}

So combining this two may look like this:

location / {
satisfy any;

allow 192.168.1.1/24;
allow 127.0.0.1;
deny 192.168.1.2;
deny all;

auth_basic "closed site";
auth_basic_user_file conf/htpasswd;
}