如何在Nginx中记录特定的IP地址?

问题描述 投票:0回答:1

我正在获取我的VPS的IP数千个连接,如下所示:

51.15.76.184 - - [17 / Dec / 2017: 16: 31: 17 -0200] "CONNECT portal.geniptv.com:8080 HTTP / 1.1" 400 172 "-" "-

这些连接已被阻止(HTTP / 1.1“400 =错误请求),但/ var / log / nginx中的access.log文件大小为几千兆字节。

如何以及在哪里可以停止专门记录此IP?

我有Debian 8与ISPconfig 3和nginx

先感谢您。

nginx debian ispconfig
1个回答
1
投票

access_log指令有一个选项,可以不根据变量的值记录请求。地图可用于设置该变量:

map $remote_addr $logging {
    default 1;
    ~^51.15.76.184$ 0;
    # ... (if there are more, consider putting them in an included file)
}

server {
    access_log  /var/log/nginx/example.com.access.log main if=$logging;
    # ...
}
© www.soinside.com 2019 - 2024. All rights reserved.