How to configure IP access in nginx?

I will give an example of setting up access by IP in nginx.

Suppose you use the standard nginx configuration file, open it in a text editor:

sudo nano /etc/nginx/sites-enabled/default

Find the string:

server {

And after it we will add networks from which it is necessary to allow access:

allow 10.0.0.0/24;
allow 172.0.0.0/11;

After the list of networks, add a line that denies access to all other unspecified networks:

deny all;

To apply the configuration changes, restart nginx:

service nginx restart

See also my article:
Install and configure Nginx

Leave a comment

Leave a Reply