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

相关推荐
caicai_xiaobai1 分钟前
Ubuntu上Git安装步骤
linux·git·ubuntu
平行云11 分钟前
实时云渲染平台数据通道,支持3D应用文件上传下载分享无缝交互
linux·unity·云原生·ue5·gpu算力·实时云渲染·像素流送
谪星·阿凯25 分钟前
Linux提权全攻略博客
linux·运维·服务器·网络安全
风度前端26 分钟前
阿里云宝塔面板部署https证书
linux·后端·https
Yeats_Liao27 分钟前
物联网接入层技术剖析(二):epoll到底是怎么工作的
java·linux·网络·物联网·信息与通信
Donk_6736 分钟前
什么是虚拟化
linux·运维
Shadow(⊙o⊙)36 分钟前
Shell进程替换,自定义Shell解释器——字符串库函数灵活操作!
linux·运维·服务器·开发语言·c++·学习
funnycoffee12338 分钟前
华为S5736交换机3层ECMP负载方式
linux·服务器·数据库
rockmelodies1 小时前
CentOS Stream 源码编译安装 Nginx 1.31.0(静态依赖版)
运维·chrome·nginx
叶半欲缺1 小时前
Linux初始化数据盘
java·linux·服务器