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

相关推荐
南棱笑笑生31 分钟前
20250509让NanoPi NEO core开发板在Ubuntu core16.04系统下实测移远的4G模块EC200A-CN
linux·运维·ubuntu
hardStudy_h36 分钟前
Linux C语言线程编程入门笔记
linux·c语言·嵌入式实时数据库
xmweisi021 小时前
Ansible内置模块之package
linux·ansible·rhce·rhca·红帽认证·it培训
xmweisi021 小时前
Ansible内置模块之service
linux·ansible·rhce·rhca·红帽认证
大神的风范1 小时前
从0开始学linux韦东山教程第一三章问题小结(1)
linux·服务器
橙色小博2 小时前
Python中的re库详细用法与代码解析
linux·python·正则表达式·php·re
10000hours3 小时前
【SGL】Scatter-Gather List内存传输技术
linux·数据结构·网络协议·list·存储·sgl
某不知名網友3 小时前
linux_进程地址空间(虚拟地址空间)
java·linux·算法
白总Server3 小时前
微软系统 红帽系统 网络故障排查:ping、traceroute、netstat
linux·运维·服务器·microsoft·中间件·架构·github
朝新_3 小时前
【Linux操作系统】第一弹——Linux基础篇
linux·服务器·网络