Linux:http配置用户登录认证访问网页

Linux:http配置用户登录认证访问网页

创建账户认证文件

bash 复制代码
# 第一次需要加-c(创建create)-m(修改)
[root@server100 ~]# htpasswd -cm /etc/nginx/.htpasswd shanxin
New password:
Re-type new password:
Adding password for user shanxin
# 第二次切记不要加-c参数,否则会覆盖上一次创建的认证信息
[root@server100 ~]# htpasswd -m /etc/nginx/.htpasswd xiaobai
New password:
Re-type new password:
Adding password for user xiaobai
[root@server100 ~]# cat /etc/nginx/.htpasswd
shanxin:$apr1$fc6WjaiJ$Rzp0MymhGORSoPPfJ6hHA0
xiaobai:$apr1$8FaGNVD2$LLLq7zmjF4wa8wc2S.VGm.

第一次需要加-c(创建create)-m(修改),第二次切记不要加-c参数,否则会覆盖上一次创建的认证信息

修改主配置文件

bash 复制代码
location /timinglee/ {
                auth_basic on;
                auth_basic_user_file "/etc/nginx/.htpasswd";
      }

重启服务

bash 复制代码
[root@server100 ~]# systemctl restart nginx
相关推荐
tntxia10 小时前
linux curl命令详解_curl详解
linux
扛枪的书生13 小时前
Linux 网络管理器用法速查
linux
SkyWalking中文站14 小时前
认识 Horizon UI · 1/17:SkyWalking 新一代可观测性控制台
运维·前端·监控
顺风尿一寸16 小时前
Java Socket 内核之旅:从 SocketChannel.read() 到 tcp_recvmsg 与 epoll 的完整调用链路
linux
雪梨酱QAQ18 小时前
Kubeneters HA Cluster部署
运维
江华森1 天前
Spring Cloud 微服务全栈实战:从 Eureka 到 Docker Compose 一文贯通
运维
江华森1 天前
Matplotlib 数据绘图基础入门
运维
XIAOHEZIcode1 天前
Ubuntu 终端美化全栈指南:Bash 到 Kitty 踩坑实录
linux·ubuntu·命令行
江华森1 天前
NumPy 数值计算基础入门
运维
唐青枫1 天前
别再只会用 cron:Linux systemd Timer 定时任务实战详解
linux