O'Reilly logo

Mastering NGINX by Dimitri Aivaliotis

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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; userid_name uid; userid_domain example.com; userid_path /; userid_expires 365d; userid_p3p 'policyref="/w3c/p3p.xml", ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required