How to configure NGINX server to block access using server IP

In this tutorial, I will try to explain how we can block access to the server when someone tries to access the server from the IP address in browser.

After following the below steps your server will only be accessed with domain name in browsers not the IP address.

1. Create a file in /etc/nginx/conf.d/. (Replace with your server’s public IP). Then add the following to your file

server {
    server_name "";
    return      444; 

2. Restart NGINX service.

sudo systemctl restart nginx 

Leave a Reply

Your email address will not be published. Required fields are marked *