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

相关推荐
hkNaruto7 分钟前
【Linux】Ubuntu 22.04 LTS GNOME 原生远程桌面配置:告别vnc、nomachine
linux·运维·ubuntu
崇子嵘1 小时前
基于zynqMPsoc15eg的linux端axi dma教训总结
linux·运维·服务器
动力 continue1 小时前
Linux 基础篇 · Vim 三种模式与常用指令
linux·运维·vim
深念Y1 小时前
系统内存与Swap优化记录
linux·内存·优化·虚拟内存·压缩·ram·zram
funnycoffee1232 小时前
Huawei USG firewall no-nat config for ipsec traffic
linux·服务器
byte轻骑兵2 小时前
【BlueZ 】蓝牙 L2CAP 协议核心:BlueZ 中基础数据传输的源码落地
linux·网络·网络协议·bluez·嵌入式蓝牙
sunoo-2292 小时前
【C 语言标准 IO 入门】第二天学习笔记:文件操作核心函数 + 实战案例 + 踩坑合集
linux·笔记·vscode·学习
波特率1152002 小时前
pthread库函数解析
linux·线程·pthread
Escalating_xu3 小时前
【Linux线程同步】从数据竞争到 mutex、条件变量与生产者消费者(上篇)
android·java·linux
晨曦花锦3 小时前
Vim基础操作与Ollama模型管理,顺便配置Nginx反向代理
linux·nginx·编辑器·vim