Ask Your Question
4

How can access for a specific IP address be denied on the HTTPS port 443 using Nginx?

asked 2022-01-15 11:00:00 +0000

qstack gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
2

answered 2022-05-10 04:00:00 +0000

scrum gravatar image

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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2022-01-15 11:00:00 +0000

Seen: 10 times

Last updated: May 10 '22