Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To deny access for a specific IP address on HTTPS port 443 using Nginx, follow these steps:

  1. Open your server block configuration file. This file is usually located in the /etc/nginx/sites-available/ directory.

  2. Add the following code inside the server block to create a new location block for HTTPS port 443:

location / {
    # Your other configuration goes here
}
  1. Add the following code inside the location block to deny access for the specific IP address:
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.

  1. Save the changes to your configuration file and reload Nginx:
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.