1

I have a LNMP stack with Varnish in front. I have a probe with Varnish and it checks every seconds if the site is running.

It works good but I don't want to log those probes.

Does someone know please how to disable only that log?

Thanks

Cœur
  • 37,241
  • 25
  • 195
  • 267
Ahmed-F
  • 147
  • 1
  • 14

1 Answers1

1

In your nginx.conf put the following inside http { ... } block:

map "$request_method:$request_uri:$remote_addr" $loggable {
    "HEAD:/:127.0.0.1" 0;
    default 1;    
}

Find your access_log directive and add the if condition to it like so:

access_log /path/to/access.log combined if=$loggable;

What this does, is logs requests conditionally: a HEAD request to / made by localhost, will not be logged. Everything else is logged as usual.

Naturally, you will have to adjust "HEAD:/:127.0.0.1" if your probe uses different request method, resource or if Varnish is not on the same machine, e.g. "GET:/healthcheck:1.2.3.4" will not log GET requests to /healthcheck by 1.2.3.4.

Danila Vershinin
  • 8,725
  • 2
  • 29
  • 35