d
Amit DhamuSoftware Engineer
 

HTTP Authentication

1 minute read 00000 views

Requirements

  • apache2-utils or httpd-tools

Generate a password

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

If you want to add multiple credentials, omit the -c flag:

sudo htpasswd /etc/apache2/.htpasswd another_user

Add the following to your Apache vhost or NGINX config

Apache

AuthUserFile /etc/apache2/.htpasswd
AuthName "Administrator's Area"
AuthType Basic

<Limit GET POST>
    require valid-user
</Limit>

NGINX

location /protected {
    auth_basic "Administrator's Area";
    auth_basic_user_file /etc/apache2/.htpasswd;
}