步骤一:安装httpd相关工具
yum -y install httpd-tools
步骤二:生成密码文件
htpasswd -c /usr/local/nginx/conf/htpasswd username 根据提示填写密码
步骤三:修改nginx配置 里添加:
server {
listen 80;
root /data/wwwroot/download;
server_name xxxxx.xxxx.xxxxx;
location ~ / {
auth_basic "User basic check";
auth_basic_user_file "conf/htpasswd";
autoindex on;
}
}
步骤四:重启nginx服务
systemctl restart nginx 或者 nginx -s reload
原文地址:https://www.cnblogs.com/sblack/p/8989371.html
时间: 2024-10-18 18:13:29