Added on Jul 17th, 2012 and marked as nginx security server

To restrict access in nginx we make use of the HttpAccessModule.

An example configuration:

location / {
  allow   2620:100:e000::8001;
  deny    all;

If you want to restrict access of several sites you can create a config file to be included in a site’s config file.

nano /etc/nginx/restrict_access

and add the IP-addresses to allow or deny. Then open the config file in /etc/nginx/sites-available and add the following line to the section you want to restrict:

# Restrict access to a group of allowed
# IP-addresses.
include restrict_access;

Now you only have to restart nginx.