Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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 "-" "-"
share|improve this question

2 Answers 2

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

Something like

location /test.html {
  access_log off;
}

should work (untested)...

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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