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

相关推荐
難釋懷1 分钟前
Nginx代理https请求
redis·nginx·https
静默追光9 分钟前
服务器——看门狗
linux·运维·服务器
无足鸟ICT10 分钟前
【RHCA+】测试变量
linux
_abab44 分钟前
Rust重塑系统编程:从Linux内核到AI推理引擎的2026全景解析
linux·人工智能·rust
初圣魔门首席弟子1 小时前
TypeScript 类型系统完全指南:从基础到高级工具类型(知识库版)
linux·运维·ubuntu
CQU_JIAKE1 小时前
7.23[a]
linux·运维·服务器
想学好C++的oMen1 小时前
socket编程TCP
linux·网络·网络协议·tcp/ip
ShirleyWang0121 小时前
Linux中Vim编辑器快速找到需要改的行
linux·编辑器·vim
盐焗鹌鹑蛋3 小时前
【Linux】基本指令
linux
海阔天空任鸟飞~9 小时前
Linux 权限 777
linux·运维·服务器