Configuring HTTP Basic Auth Protection directory under Nginx

Source: Internet
Author: User
Tags crypt

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.