Would you like to learn how to install Nginx and prevent image hotlinking? In this tutorial, we are going to configure the Apache server to deny image hotlinking on your website.

• 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 – Prevent image hotlinking

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 to your website name.

Copy to Clipboard

The NONE parameter will allow requests without a referer value direct access to images.

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 forbid hotlinking to images on our website.

In our example, the Nginx server will allow direct access to images on our website.

From a remote Linux computer, try to perform hotlinking to an image.

Copy to Clipboard

Here is the command output.

Copy to Clipboard

The Nginx server will forbid hotlinking to images on our website.

From a remote Linux computer, try to perform direct access to an image.

Here is the command output.

Copy to Clipboard

Here is the command output.

Copy to Clipboard

The Nginx server will allow direct access to images on our website.

Congratulation! You configured the nginx server to block image hotlinking.