Naming a virtual location to avoid logging results in 404s

I’m hosting a forum using Vanilla (http://www.vanillaforums.org), and
its internal statistics tracking involves no small amount of GETs and
POSTs to URIs that don’t correspond to actual directories underneath the
web root. Since every active user on the forum generates lots of these
every minute, I wanted to exclude them from being logged to keep the
server logs from growing to an unreasonable size, and so I added the
following three lines to my server config to stop logging of the three
main ones:

location /plugin/imonline { access_log off; log_not_found off; }
location /dashboard/notifications/inform { access_log off; log_not_found
off; }
location /settings/analyticstick.json { access_log off; log_not_found
off; }

Prior to adding the lines, the requests to those locations would
generate an HTTP 200 response and the corresponding analytic action
(counting thread views, showing who is online, etc) would be recorded in
the forum’s database. After adding the lines, all GETs and POSTs receive
404s, like this:

99.41.160.47 [11/Apr/2012:17:40:16 -0500] forum.chroniclesofgeorge.com:
GET /plugin/imonline HTTP/1.1 404 334
http://forum.chroniclesofgeorge.com/” “Mozilla/5.0 (Windows NT 6.0;
rv:11.0) Gecko/20100101 Firefox/11.0”

203.122.220.202 [11/Apr/2012:16:43:28 -0500]
forum.chroniclesofgeorge.com: POST /dashboard/notifications/inform
HTTP/1.1 404 736 “http://forum.chroniclesofgeorge.com/” “Mozilla/5.0
(Windows NT 6.1; WOW64) AppleWebKit/535.19 (KHTML, like Gecko)
Chrome/18.0.1025.152 Safari/535.19”

98.111.0.215 [11/Apr/2012:16:43:25 -0500] forum.chroniclesofgeorge.com:
POST /settings/analyticstick.json HTTP/1.1 404 736
http://forum.chroniclesofgeorge.com/discussions/all” “Mozilla/5.0
(Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/535.19 (KHTML, like
Gecko) Chrome/18.0.1025.151 Safari/535.19”

That’s one representative entry for each. I also realized that
“access_log off” appears to not prevent POST requests being logged, so
I’ll need to read up on the logging directive to see if there’s a way to
stop that.

I have since commented out the three lines and the analytics are being
collected again, but I wanted to ask if there is a way to not log any
GETs and POSTs to a named location without also generating 404s if those
locations don’t actually exist. Is it because of the string matching
method used in the location directive? Should I have tried ~ instead?

-Lee

Hello!

On Fri, Apr 13, 2012 at 07:41:33AM -0500, BigdinoWebmaster wrote:

location /plugin/imonline { access_log off; log_not_found off; }
GETs and POSTs receive 404s, like this:
[…]

You should add correct processing to the locations you added as
well as access_log off, likely something like proxy_pass or
fastcgi_pass:

location /plugin/imonline {
    access_log off;
    log_not_found off;
    proxy_pass http://your.backend.host;
    ...
}

Without this requests which match these locations are processed as
static, and end up with 404 as there are no corresponding files.

Maxim D.

Maxim, thanks for the reply.

There’s no backend host; there is only the one server running nginx +
php-fpm + the forum database. Should I just do a proxy_pass to
localhost, or would that create a loop and cause bad things to happen?

Alternately, should I just create empty directories and files to match
the location targets, or would that cause Nginx to try to GET and POST
them instead?

Hello!

On Fri, Apr 13, 2012 at 10:28:18AM -0500, BigdinoWebmaster wrote:

Maxim, thanks for the reply.

There’s no backend host; there is only the one server running
nginx + php-fpm + the forum database. Should I just do a
proxy_pass to localhost, or would that create a loop and cause
bad things to happen?

To pass requests to php-fpm you have to use fastcgi_pass. And you
have to duplicate this fastcgi_pass for locations you’ve added.

Maxim D.

logging of the three main ones:
action (counting thread views, showing who is online, etc) would

Maxim D.


nginx mailing list
[email protected] (mailto:[email protected])
nginx Info Page

I understand now–sorry. I was thinking that because the actual
analytics processing is done via javascript that a php passthrough for
that location wasn’t necessary, but now I see what you are saying. I
will make the change this evening.

Thanks very much for helping!