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

相关推荐
初听于你21 分钟前
IP地址与路由器地址
linux·运维·服务器·网络·tcp/ip·计算机网络·智能路由器
s_daqing36 分钟前
ubuntu(arm)使用nginx安装静态服务器
服务器·nginx·ubuntu
FJW02081442 分钟前
【Linux】SElinux的管理及优化
linux·运维·服务器
坐怀不乱杯魂1 小时前
Linux - 进程控制
linux·运维·服务器
物有本木1 小时前
httpsok-v2.0.8发布-支持IIS证书自动续签
nginx·ssl
重生之绝世牛码1 小时前
Linux软件安装 —— zookeeper集群安装
大数据·linux·运维·服务器·zookeeper·软件安装
额1291 小时前
磁盘物理卷、卷组、逻辑卷管理
linux·运维·服务器
Maggie_ssss_supp1 小时前
Linux-正则表达式
linux·运维·正则表达式
重生之绝世牛码1 小时前
Linux软件安装 —— kafka集群安装(SASL密码验证)
大数据·linux·运维·服务器·分布式·kafka·软件安装
努力的小帅2 小时前
Linux_多线程(Linux入门到精通)
linux·多线程·多进程·线程同步·线程互斥·生产消费者模型