Password protection in NGINX: Difference between revisions

From Creative Crowds wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
First, install apache2-utils
First, install apache2-utils:


  sudo apt install apache2-utils
  sudo apt install apache2-utils
Line 18: Line 18:
     auth_basic_user_file /etc/apache2/.htpasswd;
     auth_basic_user_file /etc/apache2/.htpasswd;
}
}
</ore>
</pre>
 
<small>From: https://docs.nginx.com/nginx/admin-guide/security-controls/configuring-http-basic-authentication/<small>

Latest 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;
}

From: https://docs.nginx.com/nginx/admin-guide/security-controls/configuring-http-basic-authentication/