Password protection in NGINX: Difference between revisions

From Creative Crowds wiki
Jump to navigation Jump to search
Created page with "See: https://docs.nginx.com/nginx/admin-guide/security-controls/configuring-http-basic-authentication/"
 
No edit summary
Line 1: Line 1:
See: https://docs.nginx.com/nginx/admin-guide/security-controls/configuring-http-basic-authentication/
First, install apache2-utils
 
sudo apt install apache2-utils
 
Generate a password for a specific user:  
 
sudo htpasswd -c /etc/apache2/.htpasswd octomode
 
Generate another password, for another user (this time without the -c, because that creates a new .htpasswd file):
 
sudo htpasswd /etc/apache2/.htpasswd user2
 
Configure nginx:
 
<pre>
location /octomode {
    auth_basic "This is a password protected area shared with a peer-to-peer network of trust.";
    auth_basic_user_file /etc/apache2/.htpasswd;
}
</ore>

Revision as of 21:12, 26 January 2026

First, install apache2-utils

sudo apt install apache2-utils

Generate a password for a specific user:

sudo htpasswd -c /etc/apache2/.htpasswd octomode

Generate another password, for another user (this time without the -c, because that creates a new .htpasswd file):

sudo htpasswd /etc/apache2/.htpasswd user2

Configure nginx:

location /octomode {
    auth_basic "This is a password protected area shared with a peer-to-peer network of trust.";
    auth_basic_user_file /etc/apache2/.htpasswd;
}
</ore>