Would you like to learn how to install Nginx and deny direct access to images? In this tutorial, we are going to configure the Nginx server to deny direct access to images 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.
Nginx – Related Tutorial:
On this page, we offer quick access to a list of tutorials related to Nginx.
Tutorial Nginx – Blocking direct access to images
Install the Nginx server.
Edit the Nginx configuration file for the default website.
Add the following line to the configuration file.
Change this line to your website name.
Here is the file, before our configuration.
Here is the file, after our configuration.
Restart the Nginx service.
In our example, the Nginx server will deny direct access to images on our website.
From a remote Linux computer, try to perform direct access to an image.
Here is the command output.
From a remote computer, open the browser and try to perform direct access to an image.
In our example, the following URL was entered in the Browser:
• http://www.gameking.tips/test1.jpg
The Nginx server will deny access and display an error message.
Try to access the website URL and all images will be displayed.
Congratulation! You configured the Nginx server to block direct access to images.