Would you like to learn how to install Nginx and deny access to a list of URLs? In this tutorial, we are going to configure the Nginx server to block the access to a list of pages.

• Ubuntu 18
• Ubuntu 19
• Ubuntu 20
• Nginx 1.18.0

In our example, the Nginx server is hosting the website WWW.GAMEKING.TIPS.

Equipment list

The following section presents the list of equipment used to create this tutorial.

As an Amazon Associate, I earn from qualifying purchases.

Tutorial Nginx – Blocking the access to URLs

Install the Nginx server.

Copy to Clipboard

Edit the Nginx configuration file for the default website.

Copy to Clipboard

Add the following line to the configuration file.

Copy to Clipboard

Change this line, enter the words that you want to deny access on the URL.

Copy to Clipboard

Here is the file, before our configuration.

Copy to Clipboard

Here is the file, after our configuration.

Copy to Clipboard

Restart the Nginx service.

Copy to Clipboard

In our example, the Nginx server will deny access to any URL containing the following words.

Copy to Clipboard

From a remote Linux computer, try to access a blocked URL.

Copy to Clipboard

Here is the command output.

Copy to Clipboard

If a user tries to access a URL containing the prohibited words, the request will be denied.

Congratulations! You are able to deny access to URLs containing specific words on the Nginx server.