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

相关推荐
Irene199117 小时前
两种 Linux 发行版:Ubuntu 与 CentOS Shell 环境核心差异对比(查看 Linux 版本,Hadoop 是什么)
linux·ubuntu·centos
j7~17 小时前
【Linux系统】基础IO(文件描述)(1)
linux·服务器·c++·文件·基础io
星辰&与海17 小时前
多个串口加输出
linux
广州灵眸科技有限公司17 小时前
瑞芯微(EASY EAI)RV1126B 模型部署API说明
linux·开发语言·网络·人工智能·深度学习·算法·yolo
gjc59217 小时前
Linux MySQL服务器SSH多端口配置:解决22端口禁直连,兼顾安全与运维
linux·运维·服务器·mysql·ssh
largecode18 小时前
怎么让手机显示公司名?来电显示公司名称认证实现品牌外显
linux·ubuntu·华为od·华为·智能手机·华为云·harmonyos
祁白_18 小时前
跨平台通用危险函数深度解析
linux·windows·笔记·安全·系统命令
柿柿快乐18 小时前
用户认证系统实现文档
linux·服务器·网络·学习·基础教学
南境十里·墨染春水18 小时前
linux学习进展 Redis详解
linux·redis·学习
岳来18 小时前
linux 设备目录/dev 学习
linux·服务器·/dev