Home Nginx Http Basic_auth的使用
Post
Cancel

Nginx Http Basic_auth的使用

refer to:
http://nginx.org/en/docs/http/ngx_http_auth_basic_module.html

http://www.ttlsa.com/nginx/nginx-basic-http-authentication/

nginx增加配置:

 15   location /basic_auth {
 16     auth_basic           "closed site";
 17     auth_basic_user_file /tmp/htpasswd;
 18   }

重点来了:  /tmp/htpasswd 文件要存在,而且格式为:

username:encrypted_password

例如:

admin:WrfV8OlwLBWY6

如何获得 加密后的密码?

 使用openssl 命令

# openssl passwd -crypt admin
WrfV8OlwLBWY6

This post is licensed under CC BY 4.0 by the author.
Contents