How to not log actions from a specific IP in Nginx?

Asked

Viewed 68 times

1

I’m getting thousands of connections from this IP on my VPS IP:

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

The connection is already blocked (error 400), but my access.log file in /var/log/Nginx is getting gigabytes of size per day.

How and where I stop logging this IP above specifically?

My site is Debian 8 with Ispconfig 3.1 and Nginx.

Thank you very much in advance

2 answers

1

It is possible using a condition and disabling the access_log nginx.

For this just open the file /etc/Nginx/sites-available/default and add the code below.

location ~ /(.*)$ {
    if ( $remote_addr = "51.15.76.184" ) {
        access_log off;
    }
}
  • Dear Valdeir, Thank you very much for your reply. I added the code block both in the /etc/Nginx/sites-available/default and in the /etc/Nginx/Nginx.conf and still log in. What should I do?

  • You are restarting the server? sudo nginx -s reload

  • Dear Valdeir, Good and thank you very much for the reply. I restarted the server and put that block of code but still kept getting thousands of hits per hour. What you solved was a recommendation from my veesp.com VPS server that told me there’s no way to block logging from a specific IP, but that I could ban the IP in iptables. I did the step below and now stopped logging in. iptables -A INPUT -s 51.15.76.184/32 -i eth0 -j DROP If anyone else has this problem, this is the solution

0

Dear Valdeir, dear Valdeir, Good and thank you very much for your reply. I restarted the server and put that block of code but still kept getting thousands of hits per hour.

What you solved was a recommendation from my veesp.com VPS server that told me that there is no way to block logging from a specific IP, but that I could ban the IP in iptables. I took the step below and now stopped logging in.

iptables -A INPUT -s 51.15.76.184/32 -i eth0 -j DROP

If anyone else has that problem, this is the solution

Browser other questions tagged

You are not signed in. Login or sign up in order to post.