# Turning off access\_logs for Load Balancer TCP port checks

**URL:** <https://www.ruby-forum.com/t/turning-off-access-logs-for-load-balancer-tcp-port-checks/183889>\
**Category:** NGINX\
**Created:** [February 22, 2010, 10:55am UTC](https://www.ruby-forum.com/t/turning-off-access-logs-for-load-balancer-tcp-port-checks/183889 "2010-02-22T10:55:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zev\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/eb8c5e/32.png) [@Zev\_B](https://www.ruby-forum.com/u/Zev_B)\
**Post date:** [February 22, 2010, 10:55am UTC](https://www.ruby-forum.com/t/turning-off-access-logs-for-load-balancer-tcp-port-checks/183889/1 "2010-02-22T10:55:35Z")

</div>

Hello,

We have load balancers that are doing port checks on our NGINX servers.  
Each of these checks creates an entry in our log file like this:

10.0.0.58 - - [22/Feb/2010:18:50:21 +0900] “-” 400 0 “-” “-” 0.000 “-”  
“-” “-” [-] - - - [-] [-]

Does anyone have an idea of how I can stop logging these requests?  
I have tried

location / {  
if ($remote\_addr ~\* 10.0.0..i.+) {  
access\_log off;  
}  
}

But this does not work. I have also tried putting the if and access\_log  
check in the http directive. But access\_log commands are not allowed  
there. So we might want to update the context docs here.  
[http://wiki.nginx.org/NginxHttpLogModule](http://wiki.nginx.org/NginxHttpLogModule)  
Also, I am using Nginx 0.7.65

Thanks,  
Zev

---

<div class="post-metadata">

**Author:** ![Zev\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/eb8c5e/32.png) [@Zev\_B](https://www.ruby-forum.com/u/Zev_B)\
**Post date:** [February 22, 2010, 11:39am UTC](https://www.ruby-forum.com/t/turning-off-access-logs-for-load-balancer-tcp-port-checks/183889/2 "2010-02-22T11:39:29Z")

</div>

Here is a bit more info:

On 02/22/2010 06:55 PM, Zev B. wrote:

> Also, I am using Nginx 0.7.65  
> The error log gets messages like this:

2010/02/22 19:37:35 [info] 30830#0: \*4 recv() failed (104: Connection  
reset by peer) while reading client request line, client: 10.0.0.59,  
server: [example.com](http://example.com)

Thanks,  
Zev

---

<div class="post-metadata">

**Author:** ![Zev\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/eb8c5e/32.png) [@Zev\_B](https://www.ruby-forum.com/u/Zev_B)\
**Post date:** [February 22, 2010, 1:27pm UTC](https://www.ruby-forum.com/t/turning-off-access-logs-for-load-balancer-tcp-port-checks/183889/3 "2010-02-22T13:27:10Z")

</div>

Hello!

On Mon, Feb 22, 2010 at 06:55:17PM +0900, Zev B. wrote:

> We have load balancers that are doing port checks on our NGINX servers.  
> Each of these checks creates an entry in our log file like this:
> 
> 10.0.0.58 - - [22/Feb/2010:18:50:21 +0900] “-” 400 0 “-” “-” 0.000  
> “-” “-” “-” [-] - - - [-] [-]
> 
> Does anyone have an idea of how I can stop logging these requests?

The only option you have is to turn off logging for the default  
server on the port in question (and turn it on again for  
individual locations if desired). Try something like this:

```
server {
    listen 80 default;
    access_log off;

    location / {
        access_log /path/to/log;
        ...
    }
}

```

Such “requests” doesn’t pass normal request processing pipeline as  
they aren’t really requests and even connection to client is  
already closed. They are logged in configuration context which  
happens to be here - default server’s one.

> not allowed there. So we might want to update the context docs  
> here.  
> [GitHub - nginxinc/nginx-wiki: ARCHIVED -- Source for the now archived NGINX Wiki section of https://www.nginx.com · GitHub](http://wiki.nginx.org/NginxHttpLogModule)

It’s “if” which isn’t allowed at http level, not access\_log.

Maxim D.

---

<div class="post-metadata">

**Author:** ![Zev\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/eb8c5e/32.png) [@Zev\_B](https://www.ruby-forum.com/u/Zev_B)\
**Post date:** [February 22, 2010, 1:32pm UTC](https://www.ruby-forum.com/t/turning-off-access-logs-for-load-balancer-tcp-port-checks/183889/4 "2010-02-22T13:32:27Z")

</div>

Hello,

On 02/22/2010 08:44 PM, Maxim D. wrote:

> > Does anyone have an idea of how I can stop logging these requests?  
> > access\_log /path/to/log;  
> > …  
> > }  
> > }
> 
> Such “requests” doesn’t pass normal request processing pipeline as  
> they aren’t really requests and even connection to client is  
> already closed. They are logged in configuration context which  
> happens to be here - default server’s one.

Thanks for the suggestion. That works.  
I might try making a new server default with the access\_log off just for  
it. If that does not work, I will have a lot of access\_log directives.

> > not allowed there. So we might want to update the context docs  
> > here.  
> > [GitHub - nginxinc/nginx-wiki: ARCHIVED -- Source for the now archived NGINX Wiki section of https://www.nginx.com · GitHub](http://wiki.nginx.org/NginxHttpLogModule)
> 
> It’s “if” which isn’t allowed at http level, not access\_log.

Ah yes, you are right. Sorry for the confusion.

Thanks for the options!  
Zev

---

<div class="post-metadata">

**Author:** ![Zev\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/eb8c5e/32.png) [@Zev\_B](https://www.ruby-forum.com/u/Zev_B)\
**Post date:** [February 23, 2010, 8:56am UTC](https://www.ruby-forum.com/t/turning-off-access-logs-for-load-balancer-tcp-port-checks/183889/5 "2010-02-23T08:56:05Z")

</div>

Hello,

On 02/22/2010 08:59 PM, Zev B. wrote:

> > > 
> > 
> > ```
> > location / {
> > 
> > ```
> 
> Thanks for the suggestion. That works.  
> I might try making a new server default with the access\_log off just for  
> it. If that does not work, I will have a lot of access\_log directives.

I have tried both ways.  
So far I think the best solution is make new default servers that have  
access\_log off;

I.e.

# Dummy entry to stop empty tcp opens in the logs

server {  
listen 80 default;  
access\_log off;  
}

server {  
listen 80  
server\_name [example.com](http://example.com)  
access\_log /path/to/log;  
}

This way I don’t have to put access\_log directives in all of my location  
directives.

Is this suitable or am I missing something important?

Thanks,  
Zev
