1 | initial version |
To deny access for a specific IP address on HTTPS port 443 using Nginx, follow these steps:
Open your server block configuration file. This file is usually located in the /etc/nginx/sites-available/ directory.
Add the following code inside the server block to create a new location block for HTTPS port 443:
location / {
# Your other configuration goes here
}
location / {
# Your other configuration goes here
if ($remote_addr = 10.10.10.10) {
return 403;
}
}
Replace “10.10.10.10” with the IP address you want to deny access to.
sudo service nginx reload
The above configuration will block access to the HTTPS port 443 for the specified IP address. When the IP address tries to access the server, they will receive a “403 Forbidden” error.