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

相关推荐
szxinmai主板定制专家7 分钟前
基于ZYNQ MPSOC图像采集与压缩系统总体设计方案
linux·arm开发·人工智能·嵌入式硬件·fpga开发
liulilittle20 分钟前
TCP UCP:基于卡尔曼滤波的BBR增强型拥塞控制算法
linux·网络·c++·tcp/ip·算法·c·通讯
tianrun12341 小时前
Ubuntu 24.04 安装 Fcitx5 + Rime + 搜狗词库(替代 IBus 与 Linux 搜狗输入法)
linux·运维·ubuntu
秋落风声1 小时前
内存池仿Nginx C++实现
c++·nginx
wxytxdy1 小时前
通过猜数字游戏学习Shell脚本的分支、循环编写
linux·学习
YIN_尹2 小时前
【Linux 系统编程】手撕一个简易版的shell命令行解释器
android·linux·运维
小猫咪012 小时前
Linux 软链接和硬链接详解:ln 命令背后的 inode 原理
linux
小脑斧1232 小时前
从入门到精通:Linux 进程间通信 IPC 全解析|管道、共享内存、信号量、消息队列实战
linux·运维·服务器
難釋懷2 小时前
Nginx反向代理
运维·nginx
ABCDEEE72 小时前
3.RAG
java·linux·服务器