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