ubuntu nginx配置密码访问并下载

nginx配置密码访问_htpasswd: cannot create file-CSDN博客

sudo apt-get install nginx

sudo apt install apache2-utils

复制代码
# htpasswd -c /htpasswd/passwd.db test  
htpasswd -c /etc/nginx/htpasswd.d/nginx_passwd.kibana test  

# htpasswd -c  c=create 创建文件
# /htpasswd/passwd.db 密码文件存储路径
# test 用户名  
# 回车 会让手动输入两遍密码

cd /etc/nginx

vim nginx.conf

复制代码
#添加下面内容
#user www-data;
user root;
...............
autoindex on;
auth_basic "input you user name and password";
auth_basic_user_file /etc/nginx/htpasswd.d/nginx_passwd.kibana;
include /etc/nginx/conf.d/*.conf;
 server {
                listen 80;
                root /var/www/html;
                index  index.html;
                location / {
                        index  index.php index.html index.htm;
                        autoindex on;
#                       autoindex_exact_size off;
 #                      autoindex_localtime on;
#                       auth_basic "input you user name and password";
#                       auth_basic_user_file /etc/nginx/htpasswd.d/nginx_passwd.kibana;
                }
#               location /daily_test/ {
#                       index  index.php index.html index.htm;
#               }
        }

systemctl restart nginx.service

//var/www/html 目录下放要下载的文件,或者是软连接.

相关推荐
DN金猿7 分钟前
jenkins 权限控制(用户只能看指定的项目)
linux·运维·服务器·jenkins
長安一片月9 分钟前
操作系统之进程和线程
linux·运维·服务器
悄悄敲敲敲15 分钟前
操作系统的运行-中断
linux·操作系统
代码游侠22 分钟前
学习笔记——Linux 进程管理笔记
linux·运维·笔记·学习·算法
ooolmf27 分钟前
【无标题】TemperatureMonitor.m matlab2024串口监控温度run_temperature_monitor.m
linux·运维·网络
UP_Continue35 分钟前
Linux--vim编辑器
linux·编辑器·vim
鹿衔`39 分钟前
StarRocks 4.0.2 (CDH 环境)与Paimon数据湖集成混合部署文档
linux·硬件架构·paimon·starroks
lingggggaaaa1 小时前
CS配合CrossC2插件,实现MacOS/Linux上线
linux·运维·笔记·安全·macos
shawnyz1 小时前
RHCSE--SHELL--LNMP+LAMP脚本实验
linux
TiDB 社区干货传送门1 小时前
【附操作指南】从 Oceanbase 增量数据同步到 TiDB
linux·服务器·数据库·tidb·oceanbase