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

相关推荐
m0_747124537 小时前
MIPI 屏幕移植到不同 Linux 开发板步骤(以全志平台为例)
linux·嵌入式硬件·mipi
.道阻且长.7 小时前
Linux基础IO:系统文件IO
linux·运维·服务器
女神下凡10 小时前
芯易选(146):树莓派(Raspberry Pi)_开发指南
linux·arm开发·stm32·单片机·嵌入式硬件
by2099910 小时前
Linux 软硬链接与文件删除机制
linux·服务器
我不会起名字32212 小时前
eBPF 与 perf 性能观测:On-CPU、Off-CPU 火焰图与内核探针的 4 个边界
linux·云原生·ebpf·perf·性能观测
取个没有个性的名称12 小时前
Nginx服务器配置:客户端大请求头怎样定位限制?
nginx
俊俊几年的12 小时前
RK3588 开发板详解:硬件优势与嵌入式 Linux 学习路线
linux·c++·嵌入式
信安IT租赁13 小时前
小公司服务器用户与权限管理:chmod/chown/用户组从零理清
linux·运维·服务器
Kira Skyler14 小时前
linux /proc/kallsystem 构建与解析
linux
岁月蹉跎的一杯酒15 小时前
Linux V4L2 嵌入式相机驱动点亮
linux·数码相机·isp