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

相关推荐
獨枭16 分钟前
Linux 下安装和使用 Jupyter Notebook
linux·chrome·jupyter
Monee..26 分钟前
linux里安装pip和conda
linux·conda·pip
阳区欠1 小时前
【Linux】进程通信
linux·运维·服务器·共享内存·进程通信·system v·管道文件
姓刘的哦2 小时前
Ubuntu环境安装
linux·运维·ubuntu
小小寂寞的城2 小时前
Ubuntu里安装Jenkins
ubuntu·ci/cd·docker·jenkins
再学一丢丢2 小时前
Keepalived+LVS+nginx高可用架构
nginx·架构·lvs
AdrichPro3 小时前
10、Linux C 网络编程(完整版)
linux·服务器·c语言·网络
IT 小旋风3 小时前
Linux centos 7 常用服务器搭建
linux·服务器·centos
xujiangyan_4 小时前
nginx的自动跳转https
服务器·nginx·https
千百元5 小时前
centos线程数查看
linux·运维·服务器