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

相关推荐
哈里谢顿22 分钟前
使用kvm创建一台虚拟机
linux
大喵桑丶27 分钟前
中间件快速部署(Nginx,Keepalived)
运维·nginx·中间件
爱学习的小道长1 小时前
进程、线程、协程三者的区别和联系
python·ubuntu
hanyi_qwe2 小时前
文本三剑客--awk
linux·运维·服务器
Caven772 小时前
【Linux 技巧】如何在登录时自动激活 Conda Base 环境
linux·运维·conda
凌寒112 小时前
Linux(Debian)安装、卸载 MySQL
linux·运维·mysql·debian
IT小哥哥呀2 小时前
如何从 Windows SSH 进入 VirtualBox Ubuntu 虚拟机——密码认证(逐步指南)
linux·windows·ubuntu·ssh·教程·虚拟机
paopao_wu3 小时前
目标检测YOLO[02]:YOLOv8 环境安装-Ubuntu
yolo·目标检测·ubuntu
怀旧,3 小时前
【Linux系统编程】7. 进程的概念(上)
linux·运维·服务器
7***n753 小时前
API网关设计模式
linux·服务器·设计模式