Limit nginx site to local access

You can easily configure access to a server in nginx by adding to the configuration the following:

## site.listmill.com
server {  
  server_name site.listmill.com; 

  ## Allow local users to connect
  allow 192.168.0.0/24;

  ## Deny everyone else
  deny all;

  ## Forward request
  location / {
    proxy_pass http://192.168.0.150;
    proxy_set_header Host            $host;
    proxy_set_header X-Real-IP       $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  }
}
comments powered by Disqus