What is the htpasswd?

The Apache HTTP Server can use a .htpasswd file referenced from a .htaccess file to create restricted protected areas. The .htpasswd file contains rows corresponding to a pair of username and password separated with a colon character. The password is encrypted using the UNIX system's crypt method and may use MD5 or SHA1.

This .htpasswd generator creates passwords that are hashed using the MD5 algorithm. Those passwords can be used on any platform including Windows, MacOS and Linux.

How to generate htpasswd online?

Just enter username and password and an entry for a htpasswd file is generated. This htpasswd generator creates passwords that are hashed using the MD5 algorithm, which means that you can use it for sites hosted on any platform, including Windows and Linux. If you need to create several authentication records at once, you can use bulk htpasswd generator.

To generate a secure and strong password, use password generator.


How to protect folders in apache?

To protect a specific folder, a .htaccess file is placed in the directory you want the contents of the file to affect. The rules and configuration directives in the .htaccess file will be enforced on whatever directory it is in and all sub-directories as well. A typical .htaccess file looks like the following:

AuthUserFile /path/to/.htpasswd
AuthType Basic
AuthName "My restricted Area"
Require valid-user

How to protect folders in apache?

To protect a specific folder, you need to update your website nginx config like:

location /api {
    auth_basic           "Administrator's Area";
    auth_basic_user_file /path/to/.htpasswd;
}

Alternatively, you you can limit access to the whole website with basic authentication but still make some website areas public. In this case, specify the off parameter of the auth_basic directive that cancels inheritance from upper configuration levels:

server {
    ...
    auth_basic           "Administrator's Area";
    auth_basic_user_file /path/to/.htpasswd;

    location /public/ {
        auth_basic off;
    }
}

Is it possible to save multiple entries in 1 htpasswd?

Yes, you can save multiple usernames and passwords. With each new line, there should be a new login entry.