需要将 /htdocs/website/logs 设置为对外可见,并加入密码。
# 修改 htpasswd htpasswd.txt uname
# 新增 htpasswd -db htpasswd.txt uname pwd
nginx配置如下
location /logs {
auth_basic "need passwords";
auth_basic_user_file htpasswd.txt;
autoindex on;
autoindex_exact_size off;
autoindex_format html;
autoindex_localtime on;
alias /htdocs/website/logs;
location ~ \.log$ {
add_header Content-Type text/plain;
}
}
保存之后重启nginx
本文介绍如何使用Nginx配置日志目录对外可见并设置密码保护,涉及htpasswd文件创建、Nginx配置修改及重启步骤。
422

被折叠的 条评论
为什么被折叠?



