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

相关推荐
风哥2号2 小时前
数据库教程FGMT03‑生产环境Linux+Oracle19c+ASM安装配置与项目实战
linux·数据库
一木 之林2 小时前
七、一-AI 工程实践、插件化调试与软件交付
java·linux·c++
zhengqweasd2 小时前
Linux网络(一):服务器数据包从网卡到应用程序,完整收包流程详解
linux·服务器·网络
小白羊丨2 小时前
HTTP/2 如何缓解 HTTP/1.1 阻塞;长连接对 Nginx 有什么影响?
网络协议·nginx·http
脚踏实地,坚持不懈!2 小时前
Linux 6.18.7 内存分配与回收 —— 代码梳理
linux·运维·网络
byte轻骑兵2 小时前
【BlueZ 】hci 模块:用户态 HCI 层的核心封装与消息处理
linux·人工智能·bluez·电脑蓝牙·嵌入式蓝牙
Android系统攻城狮3 小时前
Linux Gstreamer深度解析之gst_audio_format_build_integer调用流程与实战(十二)
linux·运维·服务器·音视频·车载音视频·gstreamer进阶
吴声子夜歌4 小时前
Shell脚本——流程控制:for循环
linux·运维·shell
事圆则缓4 小时前
Ubuntu 安装与配置 Samba 服务器
linux·服务器·ubuntu
GeW4 小时前
每天2小时,21天闭环计划-RHCE通关时间表全公开
linux