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 目录下放要下载的文件,或者是软连接.

相关推荐
取经蜗牛12 小时前
Ubuntu 国内镜像源配置指南(多版本常用镜像地址都有)
linux·运维·ubuntu
实心儿儿13 小时前
Linux —— 线程控制(1)
linux·运维·服务器
筠筠喵呜喵13 小时前
Linux软件开发性能优化
linux·c++·性能优化
Bruce_kaizy14 小时前
c++ linux环境编程——文件io介绍以及open 、write 、read 三剑客深度详解
linux·服务器·c++·ubuntu·操作系统·文件io
亦良Cool14 小时前
VMware虚拟机ubuntu瘦身,解决虚拟机越用越大
linux·运维·ubuntu
星辰&与海15 小时前
KVM + QEMU虚拟化方案
linux·运维
宋浮檀s16 小时前
应急响应——恶意流量&攻击行为识别
linux·运维·网络·网络安全·应急响应
REDcker16 小时前
Linux OverlayFS详解
java·linux·运维
lwx91485216 小时前
Linux系统中用户锁定后如何解锁
linux·运维·服务器
zhangrelay17 小时前
ROS 2 Lyrical Luth启程-Ubuntu26.04-
linux·笔记·学习·ubuntu