Nginx 添加 HTTP 基本认证 (HTTP Basic Authentication)
Nginx 添加 HTTP 基本认证 (HTTP Basic Authentication) 快速教程
CentOS 7 安装 Nginx
$ sudo rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
$ sudo yum install -y nginx
生成密码
$ printf "your_username:$(openssl passwd -crypt your_password)\n" >> /etc/nginx/conf.d/passwd
your_username
& your_password
替换成你的用户名密码
配置 Nginx
location / {
auth_basic "your website name";
auth_basic_user_file conf.d/passwd;
autoindex on;
}
配置完成重启 nginx
即可
最后修改于 2019-06-13
此篇文章的评论功能已经停用。