Password protection in NGINX: Difference between revisions
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 |
||
| (2 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
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; | |||
} | |||
</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/