He is a Technical professional. He is a person who loves to share tricks and tips on the Internet. He Posts what he does!
Hi All, In this document, we deal with how to restrict access by IP address in NGINX.
Nginx is one of the powerful webservers with high performance. Nginx can be used as a load balancer, reverse proxy, caching, etc.
Nginx comprises a lot of modules that help perform all these actions. Here we are explaining how we can restrict access to web server based on IP.
To allow and deny access, use allow, and deny derivatives inside the server block.
In the above example nginx accept the connection only from 192.168.10.2, rest all connection will be denied.
In the above example nginx deny the connection only from 192.168.10.2, rest all connection will be allowed.
Allow and deny derivatives can be used inside location blocks also.
In the above example nginx deny the connection only from 192.168.10.1/24 subnet, allowed only from 10.0.0.0/16 subnet and rest will be denied.
© 2020, Techrunnr. All rights reserved.