I have found some solutions to anonymize IP in nginx log - like this Anonymize IP logging in nginx?
But this will strip IP to C-subnet. Thats too much. For my purposes and GDPR compilant is in my opinion enough if the last octet of IP will be divided by 2, floored and multiplied by 2 to again. So IP will not be exact.
Can be done this in nginx / map. I did not have any luck yet.
Have a look to another law before doing this, if your website is hosted in the EU, the UE Directive 2002/58/EC requires you to store the real IP addresses between 6 month and 2 years, depending on your country within EU.
If you are hosting your website in the EU, what anonymising or pseudonimising IP adresses is only allowed after a time.
So i have answer, not pure nginx, using compiled perl.
nginx.conf
(depends on OS - this is on freebsd)
in httpd {
And then use anonymized access log format in access_log.
I dont use IPv6 so dont care about it. If you purify this, you can, I'm not familiar with perl.