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

相关推荐
leisoo80971 天前
100GBA股股票数据怎么存ClickHouseRedisMySQLJSON完整对比
大数据·linux·服务器·开发语言·python
青瓦梦滋1 天前
传输层UDP/TCP协议
linux·网络·c++·网络协议·tcp/ip·udp
ltl1 天前
机密计算:SGX、SEV-SNP、TDX 与 ARM CCA
linux
ltl1 天前
互联与网络:NVLink、InfiniBand、RoCE 与国产替代
linux
码上上班1 天前
tengine知识点
linux·服务器·centos
雾时之林1 天前
Linux--软件管理、源码包安装
linux·服务器·数据库
sxstj1 天前
Ubuntu 完整安装并启用 Flatpak 教程
linux·运维·ubuntu
国际云,接待1 天前
Nginx 后面接负载均衡,502/504 到底该先查哪里?
运维·nginx·负载均衡
RisunJan1 天前
Linux命令-sshd(SSH 服务器守护进程)
linux·服务器·ssh
天疆说1 天前
Ubuntu 26.04 下 Intel Meteor Lake 核显 + NPU 驱动配置与 PyTorch NPU 推理实测
linux·pytorch·ubuntu