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

相关推荐
尽兴-5 分钟前
如何将多个.sql文件合并成一个:Windows和Linux/Mac详细指南
linux·数据库·windows·sql·macos
kfepiza5 分钟前
Netplan 中 bridges、bonds、ethernets、vlans 之间的关系 笔记250711
linux·tcp/ip·shell
小小不董23 分钟前
深入理解oracle ADG和RAC
linux·服务器·数据库·oracle·dba
小宋0011 小时前
在Ubuntu上安装配置 LLaMA-Factory
ubuntu·计算机视觉
杰夫贾维斯2 小时前
CentOS Linux 8 的系统部署 Qwen2.5-7B -Instruct-AWQ
linux·运维·人工智能·机器学习·centos
kfepiza2 小时前
Netplan 配置网桥(Bridge)的模板笔记250711
linux·tcp/ip·ubuntu
kfepiza3 小时前
用Netplan配置网桥bridge笔记250711
linux·ubuntu·debian
CodeWithMe3 小时前
【Note】Linux Kernel 实时技术深入:详解 PREEMPT_RT 与 Xenomai
linux·运维·服务器
AI迅剑3 小时前
模块三:现代C++工程实践(4篇)第三篇《C++与系统编程:Linux内核模块开发入门》
linux·运维·服务器
专一的咸鱼哥3 小时前
Linux驱动开发(platform 设备驱动)
linux·运维·驱动开发