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

相关推荐
GDAL8 小时前
NGINX njs 全解析:从基础配置到高级特性实战
nginx·njs
dust_and_stars8 小时前
ubuntu24使用apt安装VS-code-server code-server
linux·服务器·windows
码农小韩8 小时前
基于Linux的C++学习——循环
linux·c语言·开发语言·c++·算法
ling-458 小时前
Linux-day09 11
linux·运维·服务器
202321336054 刘8 小时前
Linux常用命令分类整理
linux·运维·数据库
南工孙冬梅8 小时前
【久久派】 新世界系统安装
linux
zbguolei8 小时前
Debian提示:“用户名” 不是 sudoers 文件
linux·服务器·debian
梦星辰.8 小时前
超大 JSONL 数据集交互式查看器 Linux便捷工具
linux·windows·microsoft
optimistic_chen9 小时前
【Redis系列】主从复制
linux·数据库·redis·缓存·中间件·命令行·主从复制
zhyf1199 小时前
零刻AI Max395(Ubuntu 24.04)AMD 显卡监控工具(amdgpu_top)部署手册
linux·运维·ubuntu