This module allows you to use the user name and password based on the Basic HTTP authentication method to protect your site or part of its content.
_ Instance configuration __:
location / {: auth_basic "Restricted";: auth_basic_user_file conf/htpasswd;}
Command
[# Auth_basic]
[# Auth_basic_user_file]
Auth_basic
Syntax: auth_basic [text | Off]
Default Value: auth_basic off
Scope: HTTP, server, location, limit_0000t
This command contains the test name and password used for basic HTTP authentication. The assigned parameters are used in the authentication field. The value "off" overwrites the inheritance of upper-level commands.
Auth_basic_user_file
Syntax: auth_basic_user_file the_file
Default Value: No
Scope: HTTP, server, location, limit_0000t
This command specifies the htpasswd file name for an authentication domain.
The file format is similar to the following:
User name: Password username 2: Password 2: Comment username 3: Password 3
The password must be encrypted using the function crypt (3. You can use the htpasswd tool from Apache to create a password file.
You can also use Perl to create a password file, PW. pl content:
#!/usr/bin/perluse strict;my $pw=$ARGV[0] ;print crypt($pw,$pw)."\n";
Then begin line:
chmod +x pw.pl./pw.pl passwordpapAq5PwY/QQM
Papaq5pwy/qqm is the password of crypt.
Reference
Original document: http://sysoev.ru/nginx/docs/http/ngx_http_auth_basic_module.html