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

相关推荐
btyzadt2 小时前
虚拟机蓝屏问题排查与解决
linux·运维·网络
G_H_S_3_3 小时前
【网络运维】Shell 脚本编程:while 循环与 until 循环
linux·运维·网络·shell
coderklaus4 小时前
Shell 基础知识
linux·macos·shell
争不过朝夕,又念着往昔4 小时前
即时通讯项目---网关服务
linux·c++·vscode
时空自由民.4 小时前
linux下camera 详细驱动流程 OV02K10为例(chatgpt版本)
linux·运维·服务器
码界奇点5 小时前
Python内置函数全解析:30个核心函数语法、案例与最佳实践指南
linux·服务器·python
The_Second_Coming5 小时前
Linux 学习笔记 - 集群管理篇
linux·笔记·学习
ChuHsiang5 小时前
【Linux系统编程】日积月累——进程(2)
linux
shylyly_6 小时前
Linux->多线程2
java·linux·多线程·线程安全·线程同步·线程互斥·可重入
檀越剑指大厂6 小时前
【Nginx系列】查看 Nginx 的日志
运维·nginx