# Naming a virtual location to avoid logging results in 404s

**URL:** <https://www.ruby-forum.com/t/naming-a-virtual-location-to-avoid-logging-results-in-404s/218850>\
**Category:** NGINX\
**Created:** [April 13, 2012, 2:42pm UTC](https://www.ruby-forum.com/t/naming-a-virtual-location-to-avoid-logging-results-in-404s/218850 "2012-04-13T14:42:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [April 13, 2012, 2:42pm UTC](https://www.ruby-forum.com/t/naming-a-virtual-location-to-avoid-logging-results-in-404s/218850/1 "2012-04-13T14:42:32Z")

</div>

I’m hosting a forum using Vanilla ([http://www.vanillaforums.org](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](http://forum.chroniclesofgeorge.com):  
GET /plugin/imonline HTTP/1.1 404 334  
“[http://forum.chroniclesofgeorge.com/](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](http://forum.chroniclesofgeorge.com): POST /dashboard/notifications/inform  
HTTP/1.1 404 736 “[http://forum.chroniclesofgeorge.com/](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](http://forum.chroniclesofgeorge.com):  
POST /settings/analyticstick.json HTTP/1.1 404 736  
“[http://forum.chroniclesofgeorge.com/discussions/all](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

---

<div class="post-metadata">

**Author:** ![BigdinoWebmaster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/f19dbf/32.png) [@BigdinoWebmaster](https://www.ruby-forum.com/u/BigdinoWebmaster)\
**Post date:** [April 13, 2012, 5:20pm UTC](https://www.ruby-forum.com/t/naming-a-virtual-location-to-avoid-logging-results-in-404s/218850/2 "2012-04-13T17:20:06Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![BigdinoWebmaster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/f19dbf/32.png) [@BigdinoWebmaster](https://www.ruby-forum.com/u/BigdinoWebmaster)\
**Post date:** [April 13, 2012, 5:28pm UTC](https://www.ruby-forum.com/t/naming-a-virtual-location-to-avoid-logging-results-in-404s/218850/3 "2012-04-13T17:28:46Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![BigdinoWebmaster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/f19dbf/32.png) [@BigdinoWebmaster](https://www.ruby-forum.com/u/BigdinoWebmaster)\
**Post date:** [April 13, 2012, 5:37pm UTC](https://www.ruby-forum.com/t/naming-a-virtual-location-to-avoid-logging-results-in-404s/218850/4 "2012-04-13T17:37:27Z")

</div>

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  
> > [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) ([mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid))  
> > [mailman.nginx.org archive](http://mailman.nginx.org/mailman/listinfo/nginx)

---

<div class="post-metadata">

**Author:** ![BigdinoWebmaster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/f19dbf/32.png) [@BigdinoWebmaster](https://www.ruby-forum.com/u/BigdinoWebmaster)\
**Post date:** [April 13, 2012, 5:39pm UTC](https://www.ruby-forum.com/t/naming-a-virtual-location-to-avoid-logging-results-in-404s/218850/5 "2012-04-13T17:39:19Z")

</div>

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!
