How don't logging specif IP Address in Nginx?

1.7k Views Asked by At

I am getting on the IP of my VPS thousands of connections like this:

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

These connections are already blocked (HTTP / 1.1 "400 = Bad request), but my access.log file in /var/log/nginx is getting several gigabytes in size.

How and WHERE can i stop logging this IP specifically?

I have Debian 8 with ISPconfig 3 and nginx

Thank you in advance.

1

There are 1 best solutions below

1
On

The access_log directive has an option to not log requests based on the value of a variable. A map can be used to set that variable:

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;
    # ...
}