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

相关推荐
特立独行的猫a5 分钟前
在 Windows 10 上安装和使用 WSL 2 安装 Ubuntu24详细指南
windows·ubuntu·wsl2
倔强的石头1066 分钟前
KaiwuDB社区版 3.1.0 在 Ubuntu 22.04 部署实战:TLS 配置、踩坑复盘与轻量压测
数据库·ubuntu·kwdb
liwenzhuola6 分钟前
解决 Ubuntu 上 Qt Creator 项目编译失败的问题
数据库·qt·ubuntu
济6177 分钟前
ARM Linux 驱动开发篇---基于 pinctrl+GPIO 子系统的蜂鸣器驱动开发(设备树版)--- Ubuntu20.04
linux·嵌入式·嵌入式linux驱动开发
AiGuoHou111 分钟前
Debian/Ubuntu 各个版本一键更换国内镜像源
linux·ubuntu·国内源·debian·镜像源·换源
衡动科技11 分钟前
Ubuntu 22.04/24.04 安装 ROS2 完整教程(Humble / Jazzy)
ubuntu·树莓派·ros2
蓝羽天空11 分钟前
Ubuntu 24.04 安装 Docker
linux·ubuntu·docker
T0uken11 分钟前
WSL:离线配置 Ubuntu 开发环境
linux·运维·ubuntu
�羡阳丶12 分钟前
ubuntu22.04+5060显卡双系统安装,各种黑屏踩坑记录
linux·经验分享·ubuntu
b_xinjun112012 分钟前
树莓派 Ubuntu 24.04.3 LTS 安装 OpenClaw 操作说明
linux·ubuntu·arcgis