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

相关推荐
panplan.top20 分钟前
Tornado + Motor 微服务架构(Docker + 测试 + Kubernetes)
linux·python·docker·微服务·k8s·tornado
FJW02081436 分钟前
【Linux】系统中的文件管理
linux·运维·服务器
豆是浪个36 分钟前
Linux(Centos 7.6)命令详解:rpm
linux·运维·centos
-指短琴长-1 小时前
Docker基础【Ubuntu安装/Windows安装】
windows·ubuntu·docker
Z_Xshan1 小时前
docker 容器web站点 中文文件名访问404问题
linux·开发语言·docker
晓梦.2 小时前
Linux
linux·运维·服务器
运维帮手大橙子2 小时前
Linux如何安装使用Rust指南
linux·运维·rust
千百元2 小时前
centos怎么查看磁盘是机械还是固态
linux·运维·centos
LoneEon2 小时前
CentOS 7 系统安装教程
linux·运维·centos
ssswywywht3 小时前
搭建本地时间同步服务器
linux·运维·服务器