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

相关推荐
liujing102329293 小时前
stm32大项目阶段20251015
linux
嵌入式郑工4 小时前
LINUX驱动开发: 设备和驱动是怎么匹配的?
linux·运维·服务器
zhuyan1085 小时前
【远程桌面】在ubuntu中安装远程桌面
ubuntu
郭式云源生法则5 小时前
归档及压缩、重定向与管道操作和综合使用,find精确查找、find处理查找结果、vim高级使用、vimdiff多文件使用
linux·运维·服务器
一张假钞5 小时前
Ubuntu 24.04 安装 Jenkins
linux·ci/cd·jenkins
tuokuac6 小时前
查看你电脑上某个端口正在被哪个进程占用
linux
小池先生6 小时前
服务请求出现偶发超时问题,经查服务本身没问题,问题出现在nginx转发。
运维·服务器·nginx
MANONGMN6 小时前
Linux 通配符与正则表达式(含实战案例+避坑指南)
linux·运维·正则表达式
带土16 小时前
18 .shell编程-正则表达式
linux·正则表达式
爱吃甜品的糯米团子6 小时前
Linux 学习笔记之进程管理、网络基础与常用软件安装
linux·网络·学习