Configuring Nginx to Display 404 Page for Unconfigured Domains and Server IP Address

| Servers & Config | 51 seen

In today's digital age, it is crucial for website owners to have a properly configured web server.

This not only ensures a smooth and seamless user experience but also protects the website from potential security threats.

One common issue that website owners face is incorrectly indexed links in search engines like Google. In this article, we will provide a simple guide on how to configure Nginx to display a 404 page for unconfigured domains and your server's IP address.

The first step in this process is to create a dummy or default domain folder. This folder will serve as a redirect for all incorrect requests made to the website. To create this folder, open the terminal and enter the following commands:

sudo mkdir -p /srv/www/default sudo usermod -a -G www-data admin sudo chown -R www-data:www-data /srv/www sudo chmod -R 775 /srv/www

Once the dummy domain folder has been created, the next step is to configure Nginx server blocks for this folder. Open the Nginx configuration file by entering the following command in the terminal:

sudo nano /usr/local/nginx/sites-available/default

In the Nginx configuration file, paste the following code:

server{ listen 80 default; root /srv/www/default; }

Next, enable the domain by creating a symbolic link between the available and enabled folders in Nginx:

sudo ln -s /usr/local/nginx/sites-available/default /usr/local/nginx/sites-enabled/default

The final step is to create a basic HTML index.html file and upload it to the /srv/www/default folder. This file will display the content that will be shown when accessing the server's IP address or an unconfigured domain.

After uploading the index.html file, restart Nginx by entering the following commands in the terminal:

sudo /etc/init.d/nginx stop sudo /etc/init.d/nginx start

Now, try accessing the server's IP address in a web browser. You should see the content from the index.html file that you created.

In conclusion, configuring Nginx to display a 404 page for unconfigured domains and server IP addresses is a simple process that can help to protect your website from potential security threats and ensure a smooth user experience.

 

Latest articles

Berlin Zoo and Aquarium: One of the Best Things To Do in Berlin With Kids

At the start of April 2026, during our roughly five-day trip to Berlin, we finally visited the famous Berlin Zoo for the first time - or at least the first time I can actually remember. There is a chance my mom might have taken me here sometime in the early 1990s, but if so, those memories are long gone. This visit felt completely new, and…

Germany |

Berlin Brandenburg Airport

In April 2026, I had my first experience with Berlin Brandenburg Airport (BER) while flying the Riga–Berlin–Riga route with airBaltic. This was my first time using Berlin’s main international airport, and overall, it left a solid impression—modern, functional, and relatively easy to navigate. About a decade ago, I had the chance to travel through…

Germany |