我需要从访问日志中排除所有具有指定地址的记录,为此我写道:
map $remote_addr $no_log_by_ip {
"xx.xx.xx.xx" 0;
default 1;
}
access_log /path_to_log/access.log combined if=$no_log_by_ip;
还需要从访问日志中排除所有代码为 403 的记录,我写道:
map $status $no_log_by_status {
403 0;
default 1;
}
access_log /path_to_log/access.log combined if=$no_log_by_status;
它是单独工作的。我们如何才能使这两种条件同时发挥作用,即这样日志中就没有指定 IP 的条目和来自任何 IP 的 403 条目了吗?
尝试过:
access_log /path_to_log/access.log combined if=$no_log_by_status if=$no_log_by_ip;
但只有最后一个 if 有效,即在这种情况下,if=$no_log_by_ip。