Nginx Basic AUTH Instructions
Syntax: Auth_basic string | Off
Default value: Auth_basic off;
Configuration segment: HTTP, server, location, limit_except
By default, authentication is not turned on, and the characters are displayed in the popup window if they are followed by characters.
Syntax: Auth_basic_user_file file;
Default value:-
Configuration segment: HTTP, server, location, limit_except
1. Download this python file: http://trac.edgewall.org/export/10770/trunk/contrib/htpasswd.py (recommended in Nginx wiki)
chmod 777 htpasswd.py #给文件加上权限. /htpasswd.py-c-b htpasswd username password#-c to generate file htpasswd as file name
-D is encrypted with crypt
Username for login name password login password
2. You can use HTPASSWD or create a password using OpenSSL
" ttlsa:$ (OpenSSL passwd-crypt 123456) \ n " >>conf/cat conf/htpasswd ttlsa:xyjkvhxgaz8tm
3. Place the htppasswd file under the nginx/conf file and edit the nginx.conf file
add two lines to the location: Auth_basic " Password " ; auth_basic_user_file conf/htpasswd;
4. Restart Nginx Service
Service Nginx Start
5. Note the error alert: Description 43 line is wrong
6. You can use Curl-v http://localhost to view the status code returned by http: 401 Unauthorized representation of success
7. The default access address in the browser is http://localhost
Configuring HTTP Basic Auth Protection directory under Nginx