When starting my blog, I decided that I do not want to store any personal information about the people visiting my blog. I was definitely interested in some metrics, but my users should stay anonymous as far as possible.
For the metrics part, I am using Plausible. Storing the country of my visitors is anonymous enough, so I am fine with that.
Some thing I was not happy about until now was that I decided to not store any server logfiles. Sometimes these logfiles come in really handy, so I wanted to fix that somehow. In the end, the configuration was surprisingly simple.
Define my own log format
nginx allows to define any log format. I decided to keep with the original format as close as possible, just without IP address and referrer. For that, I created the file /etc/nginx/conf.d/redacted_log.conf and added the following:
log_format anonymous_log '0.0.0.0 - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"(redacted)" "(redacted)"';
I decided to stay close to the usual format as close as possible. Setting 0.0.0.0 as the IP was a plain decision I took, so that when looking at it, I will immediately be irritated. If I would have chosen any real IP, I may have misunderstood that… {< linebreak >}
In addition, this choice does not break the nginx logfile format, which helps other applications reading these files.
Use the new log format
Using the new format was nearly as simple. Typically, in the nginx configuration there is the line access_log /var/log/nginx/something.log;. Now newly, I have got access_log /var/log/nginx/something.log anonymous_log;.
Conclusion
Doing things anonymously is not that hard, I just have to find the time to do it!