Amit Dhamu

Software Engineer

HTTP Authentication

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


http / authentication / security / apache / htaccess / nginx

← Toggle Text Function Double Click Event →