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

相关推荐
若无情我 纸小铭4 分钟前
Nginx学习笔记(二) Nginx--connection&request
笔记·学习·nginx
xixingzhe212 分钟前
net::ERR_INCOMPLETE_CHUNKED_ENCODING解决
nginx
.冰块.16 分钟前
P-SAN 实战:CentOS7 搭建 iSCSI Target 共享块存储
linux·服务器·iscsi
Kina_C23 分钟前
Keepalived 单播模式实战:跨网络高可用的关键配置
linux·服务器·网络·keepalived
m0_743697591 小时前
磁盘管理的相关知识
linux
先知后行。1 小时前
内核中的侵入式链表,slub对象池,CAS
linux
艾莉丝努力练剑2 小时前
Mac 远程桌面体验:6 个工具的 macOS 适配情况整理
linux·运维·服务器·macos·面试
酷可达拉斯2 小时前
Linux操作系统-tcpdump抓包定位网络问题实战
linux·运维·服务器·网络·tcpdump
byte轻骑兵2 小时前
BlueZ 5.x 整体架构总览:用户态 + 内核态分层设计核心逻辑
linux·架构·bluez·电脑蓝牙·嵌入式蓝牙
ltl10 小时前
大多数「无锁」代码其实不是无锁的
linux