Nginx 配置账号访问
1.下载httpd服务
dnf install httpd-tools -y
2.创建用户
htpasswd -cb passwd zhangsan redhat
htpasswd -b passwd lisi redhat
3.修改权限
chmod 600 password
chown 600 password
4.添加对应的服务器名称
vim /etc/hosts
192.168.232.130 account.com
vim account.conf
server{
server_name account.com;
root /var/www/account.com/;
location /admin{
index index.html;
auth_basic "login passwd ";
auth_basic_user_file /etc/nginx/conf.d/password;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
}
mkdir -p /var/www/account/
echo account > /var/www/account/index.html
mkdir -p /var/www/account/admin
echo accoumt admin > /var/www/account/admin/index.html
systemctl restart nginx
curl account.com
curl http://zhangsan:redhat@www.account.com/admin/index.html