website/content/blog/privacy-friendlier-nginx-logging.md
2022-04-10 13:07:40 +02:00

726 B

title author date featured_image categories tags draft type
Privacy friendlier Nginx logging Vrifox 2021-05-15T21:49:54+02:00 true post

Yesterday I changed the logging behaviour of my nginx. I did this to make it more privacy friendly and to declutter my log files.
The ip address anonymization part is taken from Ascraues Privacy Policy .

map $remote_addr $anon_remote_addr {
  ~(?P<ip>\d+\.\d+)\.         $ip.0.0;
  ~(?P<ip>[^:]+:[^:]+):       $ip::;
  default                     0.0.0.0;
}

log_format privacy '$anon_remote_addr [$time_local] '
                   '"$request" $status $bytes_sent ';

access_log  /var/log/nginx/access.log privacy;