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
相关推荐
orion5729 分钟前
Missing Semester Class1:course overview and introduction of shell
linux
SkyWalking中文站5 小时前
认识 Horizon UI · 6/17:Trace 探索器
运维·监控·自动化运维
用户120487221617 小时前
Linux驱动编译与加载
linux·嵌入式
火车叼位8 小时前
写给初级开发者:SSL、SSH、HTTPS 与证书体系全解析
运维
用户8055336980313 小时前
Input 子系统架构:Core、Handler、Driver 三层是怎么协作的
linux·嵌入式
用户8055336980313 小时前
RK-Forge外设系列开篇 - 把板子从「能启动」变成「能用」:Ethernet/SPI/MMC 三个纯接线外设
linux·github·嵌入式
小猿姐20 小时前
唯品会大规模数据库云原生实践:基于 KubeBlocks 管理数千实例的统一运维之路
运维·elasticsearch·云原生
七歌杜金房1 天前
我终于又有了自己的 Linux 电脑
linux·debian·mac
SkyWalking中文站1 天前
认识 Horizon UI · 5/17:3D 基础设施地图
运维·监控·自动化运维
tntxia2 天前
linux curl命令详解_curl详解
linux