From b470fddc1296c66c7e2cf070071ddf1bbe06af50 Mon Sep 17 00:00:00 2001 From: Franziska Kunsmann Date: Sat, 20 Feb 2021 21:11:12 +0100 Subject: [PATCH] bundles/nginx: add gdpr-compatible log format --- bundles/nginx/files/nginx.conf | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/bundles/nginx/files/nginx.conf b/bundles/nginx/files/nginx.conf index b2fcf10..5943dee 100644 --- a/bundles/nginx/files/nginx.conf +++ b/bundles/nginx/files/nginx.conf @@ -35,5 +35,24 @@ http { '' close; } + # GDPR compatible IP smashinator 5000000 + map $remote_addr $ip_anonym1 { + default 0.0.0; + "~(?P(\d+)\.(\d+))\.(\d+)\.\d+" $ip; + "~(?P[^:]+:[^:]+):" $ip; + } + map $remote_addr $ip_anonym2 { + default .0.0; + "~(?P(\d+)\.(\d+)\.(\d+))\.\d+" .0.0; + "~(?P[^:]+:[^:]+):" ::; + } + map $ip_anonym1$ip_anonym2 $ip_anonymized { + default 0.0.0.0; + "~(?P.*)" $ip; + } + log_format gdpr '$ip_anonymized - $remote_user [$time_local] ' + '"$request" $status $body_bytes_sent ' + '"" "$http_user_agent"'; + include /etc/nginx/sites/*; }