Install the Nginx server.
Edit the Nginx configuration file for the default website.
Add the following line to the configuration file.
Here is the file, before our configuration.
Here is the file, after our configuration.
Create a file containing the list of IP addresses.
Here is the file content.
Configure the file permission.
Restart the Nginx service.
In our example, the Nginx server will forbid access from IP addresses included on the file named BLACKLIST.
In our example, we blocked the entire network 192.168.1.0/24.
In our example, we blocked the IP address 192.168.2.102.
From a computer included on the list, try to access the Nginx server.
The Nginx server will deny access and display an error message.
The Nginx server will deny access based on the access list file named BLACKLIST.
Congratulations! You are able to deny access to the Nginx server based on the source IP address.