Then add in the corresponding Server section in the nginx.conf file
Location ^~/test/{
Auth_basic Test-login;
AUTH_BASIC_USER_FILE/ROOT/HTPASSWD;
Then/root/create a new file in the home directory of root htpasswd
The writing format for this file is
User name: Password
One account per line
And the password must be encrypted using the function crypt (3)
The official file says you can use Apache's htpasswd tool to create password files.
Of course, you can create a new pw.pl file with Perl by creating a password file that reads:
Copy Code code as follows:
#!/usr/bin/perl
Use strict;
My $pw = $ARGV [0];
Print crypt ($PW, $PW). " n ";
Then execute chmod +x pw.pl
./pw.pl Password
Papaq5pwy/qqm
PAPAQ5PWY/QQM is Password's crypt () password.
And then the encrypted password, which is generated with Perl,
According to
User name: Password
The format is written to the htpasswd file
This completes the setup
If you don't
^~/test/
And with
/test
Then the directory will only be authenticated. Direct access to files under it will not eject logon verification
And htpasswd, the name of this file can be set at your own discretion.
User name is also set at your own discretion without encryption
Password must be encrypted using function crypt (3)