To respect the privacy of my users I\'m trying to anonymize their IP addresses in nginx log files.
One way to do this would be defining a custom log format, like so:<
The accepted answer seems a bit bloated. Since nginx version 1.11 it's possible to do it this way:
map $remote_addr $remote_addr_anon { ~(?P\d+\.\d+\.\d+)\. $ip.0; ~(?P[^:]+:[^:]+): $ip::; default 0.0.0.0; }