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

相关推荐
凡间客1 小时前
Ansible安装与入门
linux·运维·ansible
君以思为故1 小时前
认识Linux -- 进程概念
linux·服务器
_OP_CHEN1 小时前
Linux网络编程:(八)GCC/G++ 编译器完全指南:从编译原理到实战优化,手把手教你玩转 C/C++ 编译
linux·运维·c++·编译和链接·gcc/g++·编译优化·静态链接与动态链接
阿乐艾官1 小时前
【十一、Linux管理网络安全】
linux·运维·web安全
百***67032 小时前
Nginx搭建负载均衡
运维·nginx·负载均衡
Code Warrior3 小时前
【Linux】Socket 编程预备知识
linux·网络·c++
摘星|4 小时前
架设一台NFS服务器,并按照以下要求配置
linux·运维·服务器
做运维的阿瑞4 小时前
Linux环境变量持久化完全指南
linux·运维·服务器
天才奇男子4 小时前
从零开始搭建Linux Web服务器
linux·服务器·前端
DY009J5 小时前
如何在Ubuntu虚拟机中设置Samba共享,并在Windows宿主机中挂载为网络驱动器
网络·windows·ubuntu