Back

nginx - http - basic auth的使用

发布时间: 2023-04-24 10:40:00

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

Back