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

Did my article help you? How about buying me a cup of coffee as an encouragement? Buy me a coffe.

Leave a comment

Leave a Reply