Nginx/HttpAuth

来自OSSmedia
Brucekomike讨论 | 贡献2024年3月9日 (六) 12:03的版本 (创建页面,内容为“分类:教程 本文介绍如何配置 Nginx 的http basic auth == Ubuntu/debian == 软件包 sudo apt instal apache2-utils 创建密码文件 sudo htpasswd -c /etc/apache2/.htpasswd user1 创建第二个用户,因为文件已经存在,所以不需要 -c 参数 sudo htpasswd /etc/apache2/.htpasswd user2 == nginx 配置文件 == location /api { auth_basic "Administrator’s Area"; auth_basic_user_file /etc/apache2/.htpasswd; }”)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)

本文介绍如何配置 Nginx 的http basic auth

Ubuntu/debian

软件包
sudo apt instal apache2-utils
创建密码文件
sudo htpasswd -c /etc/apache2/.htpasswd user1
创建第二个用户,因为文件已经存在,所以不需要 -c 参数
sudo htpasswd /etc/apache2/.htpasswd user2

nginx 配置文件

location /api {
   auth_basic           "Administrator’s Area";
   auth_basic_user_file /etc/apache2/.htpasswd; 
}