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

相关推荐
科力锐品牌君33 分钟前
应用级灾备 | 海量非结构化数据如何实现高效数据保护
linux·运维·网络·安全·系统安全·数据安全·灾备
zhangrelay44 分钟前
ROS项目设计案例智能大模型正经乱答案例
linux·笔记·学习·ubuntu·机器人
流浪0011 小时前
Linux系统篇39——线程(四) pthread库的由来和线程的创建与等待
linux·操作系统·线程·pthread库
Lancker2 小时前
chnroute-linux — 中国大陆 IP 段每日自动更新 + 「仅允许国内访问」落地
linux·运维·tcp/ip
高山有多高2 小时前
【Linux笔记】Linux进程与守护进程
linux
大侠归来3 小时前
Ubuntu 搭建 APUE 环境:从源码编译到第一个示例跑通
linux·运维·ubuntu
shdkfbbv4 小时前
【无标题】
linux·运维·服务器
周洲08305 小时前
STM32片内Flash读写深度详解|掉电参数保存、底层原理
linux·前端·stm32
shimly1234565 小时前
比 find + grep 更好用的 nm + addr2line
linux
迷途之人不知返5 小时前
【进程控制】-3-进程等待
linux