up vote 0 down vote favorite
share [g+] share [fb]

I'm running nginx behind haproxy (running on the same server). I've configured haproxy to use a simple html file on nginx to verify the service is up, since I don't have/want a valid "/" URL on this host. Nginx doesn't support the OPTIONS request type (as far as I know) which is the default that haproxy uses, so I've changed it to a GET.

Since I have access logs turned on in nginx, I'm getting all these uptime poll requests in my access log. Is there a way that I can configure nginx to ignore certain requests, and skip logging them?

Here's the haproxy backend:

backend static_http
        option  httpchk GET /test.html
        option  redispatch
        balance roundrobin
        #fullconn 1000
        server  w1_static www1:81 check port 81 inter 2000

And Here's what I see in the nginx logs:

127.0.0.1 - - [24/Jul/2009:19:28:22 +0000] "GET /test.html HTTP/1.0" 200 12 "-" "-"
127.0.0.1 - - [24/Jul/2009:19:28:24 +0000] "GET /test.html HTTP/1.0" 200 12 "-" "-"
127.0.0.1 - - [24/Jul/2009:19:28:26 +0000] "GET /test.html HTTP/1.0" 200 12 "-" "-"
127.0.0.1 - - [24/Jul/2009:19:28:28 +0000] "GET /test.html HTTP/1.0" 200 12 "-" "-"
127.0.0.1 - - [24/Jul/2009:19:28:30 +0000] "GET /test.html HTTP/1.0" 200 12 "-" "-"
link|improve this question
feedback

2 Answers

Well, you could try having a specific location directive for this.

Something like

location /test.html {
  access_log off;
}

should work (untested)...

link|improve this answer
feedback

There's no built-in filtering that will do what you want.

There are a few tricks you might try though. These will all result in the data you're not interested in being logged to a different file, which you can nuke externally (remember to HUP nginx afterwards) as often as you feel is appropriate.

  • if haproxy is the only thing that requests /test.html, you can have a different access log per location block (unfortunately not for an if block inside a location block).

  • if other nodes request /test.html but all requests from 127.0.0.1 are haproxy, you could create a map based on $remote_addr that translates 127.0.0.1 to access_log.junk and everything else to access_log. Use the map variable in the name of the access log statement

Failing that, you've got the source, so hack what you need in.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.