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:<
I think, a good and practicable solution is to anonymize the IP before rotating your log files (which you should do daily). There are lot's of scripts for this task available for the Apache, and since the log format is at least very similar, they should work out of the box or be easily adjustable. Of course, you still store the full IP for 24 hours or less, but that's better than having them laying around for years.