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

相关推荐
问天_观心8 分钟前
虚拟环境WSL之Ubuntu的安装
人工智能·ubuntu
weixin_3077791316 分钟前
PHP 大文件上传:内存占用、超时与最佳实践
linux·服务器·开发语言·nginx·php
闲云野鹤在人间21 分钟前
项目实战:LNMP-电商平台-ECshop
linux·运维·nginx·apache·lvs
吹什么轩38 分钟前
linux网络:UDP套接字的业务实现:字典
linux·运维·udp
迷途之人不知返40 分钟前
gcc编译器,以及源文件的翻译
linux
啊啊啊啊啊!!!!1 小时前
【Linux】初始Linux操作系统
linux·运维·服务器
runafterhit2 小时前
【学习地图】Linux学习类 · 文章索引
linux·运维·学习
码农阿豪2 小时前
Ubuntu部署GodoOS:Docker搭建Web办公桌面并实现远程访问
前端·ubuntu·docker
杨云龙UP2 小时前
Oracle ASH 报告详解:与 AWR 的区别、使用场景及生成方法
linux·运维·服务器·数据库·oracle
琥珀色糖3 小时前
Linux makefile
linux·运维·服务器·makefile·make