Would you like to learn how to install Nginx and configure the basic authentication feature on a computer running Ubuntu Linux? In this tutorial, we are going to configure the Basic authentication feature on the Nginx server.
• Ubuntu 18
• Ubuntu 19
• Ubuntu 20
• Nginx 1.18.0
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 – Basic authentication
Install the Nginx server and the required packages.
Create the Nginx password file and add the first user account.
The system will request you to enter the password to the new user account.
Here is the file content.
To create additional user accounts, use the following command.
Edit the Nginx configuration file for the default website.
Insert the following line in the area named LOCATION.
Here is the file content.
Restart the Nginx service.
Open your browser and enter the IP address of your web server.
In our example, the following URL was entered in the Browser:
• http://172.31.8.195
The Nginx server will require you to perform the user authentication.
In our example, the configuration required user authentication to access any part of the website.
In the next example, we will require authentication only to users trying to access a subdirectory named: SECURE.
Congratulations! You are now able to use the Nginx basic authentication.