Chapter 7
[ 185 ]
location = @empty {
access_log off;
empty_gif;
}
The size parameter to image_filter deserves special mention. When this parameter
is configured for a location, information about the image is delivered instead of the
image itself. This could be useful in your application for discovering metadata about
an image before calling a resize or crop URI:
location /img {
image_filter size;
}
The result is a JSON object such as the following:
{ "img" : { "width": 150, "height": 200, "type": "png" } }
Tracking website visitors
A fairly unobtrusive way to track unique website visitors is to use the userid module.
This module sets cookies that are used to identify unique clients. The value of these
cookies is referenced by the $uid_set variable. When that same user returns to the
site and the cookie is still valid, the value is available in the $uid_got variable. An
example of how to use these is as follows:
http {
log_format useridcomb '$remote_addr - $uid_got [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent"';
server {
server_name .example.com;
access_log logs/example.com-access.log useridcomb;
userid on;