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

相关推荐
小张同学a.35 分钟前
LAMP架构2
linux·运维·网络·架构·负载均衡
千河殇 多想和她37 分钟前
如何在Reaonix中使用CodeGraph以及CodeGraph效果实测经验分享
linux·运维·ubuntu
躺不平的理查德1 小时前
CMAKE备忘录
linux·运维·服务器
面对疾风叭!哈撒给1 小时前
Linux ARM架构的docker和docker-compose离线安装
linux·docker·架构
阿虎儿2 小时前
Linux 下为局域网 IP(如 192.168.1.100)打造不受浏览器警告的自签名 SSL/TLS 证书
linux·安全·https
小王C语言2 小时前
虚拟机开机过程中关机,再次开机没有分配 IP
linux·网络·tcp/ip
诸葛老刘2 小时前
Ubuntu 服务器常用运维命令
运维·服务器·ubuntu
薛定谔的悦2 小时前
光储系统 AEMS 模块的光伏控制模式设计
linux·能源·储能·bms
码农客栈3 小时前
U-Boot详解(三)之启动流程详解
linux·uboot
say_fall3 小时前
【Linux系统编程】文件操作基础:C标准库、系统调用、fd是什么和fd与FILE*的关系
android·linux·c语言