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

相关推荐
babytiger9 小时前
Gitea 重安装 + Snap 数据迁移完整流程总结
linux·elasticsearch·gitea
匆匆那年9679 小时前
远程 Linux 校园网认证操作手册(本地浏览器法)
linux·运维·服务器
newnazi9 小时前
RedHat10 安装MS SQL Server2025
linux·服务器·数据库
zkkkkkkkkkkkkk10 小时前
Linux进行管理工具Supervisor配置与使用
linux·python·supervisor
开发者联盟league10 小时前
linux普通用户使用pip安装模块
linux·python·pip
QuestLab10 小时前
③-进阶篇:vLLM实战——多卡部署、压测与排障
linux·服务器·网络
Languorous.10 小时前
Windows 安装 Linux 虚拟机 / WSL 完整教程(新手零失败)
linux·运维·windows
颂love11 小时前
Linux命令的简单学习
linux·运维·学习
HEADKON11 小时前
培西达替尼Pexidartinib对比伊马替尼在腱鞘巨细胞瘤中的CSF1R抑制与肝毒性风险
nginx
satadriver11 小时前
ip-guard网络通信加解密
linux·网络·tcp/ip