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

相关推荐
qq_54702617912 小时前
Linux 常用快捷键及文本编辑器
linux·运维·服务器
埃伊蟹黄面13 小时前
磁盘级文件系统核心原理解析
linux·文件
醇氧13 小时前
【Linux】 安装 Azul Zulu JDK
java·linux·运维
小康小小涵13 小时前
睿抗机器人大赛魔力元宝
python·ubuntu·gitee·github
一直跑14 小时前
查看显卡驱动版本,查看哪个用户使用显卡(GPU)进程
linux·服务器
滴水之功14 小时前
Windows远程桌面(非图形化界面)连接Ubuntu22.04
linux
借你耳朵说爱你15 小时前
在Linux上挂载磁盘
linux
小成2023032026515 小时前
Linux高级
linux·开发语言
ICT系统集成阿祥15 小时前
Linux运维最万能的三条指令
linux·运维·服务器
CAU界编程小白16 小时前
Linux系统编程系列之模拟文件操作
linux·算法