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

相关推荐
老一岁3 小时前
csdn-mysql索引与redis命令
linux
handsome_sai5 小时前
《Linux 小白查看系统与软件商店指南》
linux·运维·服务器
Rabitebla5 小时前
【Linux】 文件系统(五):挂载与软硬链接,多个文件系统怎样组成统一目录树
linux·运维·服务器·c++·笔记·学习·算法
皓月盈江6 小时前
云服务器上部署Hexo静态博客
linux·服务器·hexo·个人博客·云服务器·个人网站·静态博客
遥夜人间6 小时前
Nginx 纳入 systemd 管理
运维·网络·nginx
qeen877 小时前
【Linux】线程的基本认识及与进程的关系、对比
linux·运维
疯华整猫8 小时前
一条 kill -9 杀不掉的进程:AI 时代,程序员为什么必须精通 Linux
linux
爆米花byh11 小时前
在RockyLinux9环境下安装Rust1.100.0环境
linux·rust
爆米花byh11 小时前
在RockyLinux9环境下安装Manticore Search32.1.3单机版
linux·服务器·搜索引擎
大今野11 小时前
技能六 · Linux(CentOS 7)操作系统章节习题
linux·运维·centos·专转本