Anonymize IP logging

Hello,

i’m searching for an way to anonymize the ip address in the logfiles
of nginx. I already changed the ip to “127.0.0.1”, but then i can’t
check for unique visitors.
There is a mond_anonstats modul available for apache, the same ip hash
would be really nice for nginx.

Thanks

Hello

I’m not sure if its performance wise, but you can always define your own
log format Module ngx_http_log_module with a custom
variable instead of $remote_addr which can be almost anything, try using
for example Lua | NGINX ngx.md5 or any lua code
:wink:

Regards

M

I’m not sure if its performance wise, but you can always define your own
log format Module ngx_http_log_module with a custom
variable instead of $remote_addr which can be almost anything, try using
for example Lua | NGINX ngx.md5 or any lua code :wink:

Or perl code, which is even easier, than lua :slight_smile:

perl_set  $anon_addr  ' sub {
    use Digest::MD5 qw(md5_hex);
    my $r = shift;
    md5_hex $r->remote_addr
} ';

2012/5/3 Alexandr G. [email protected]:

Or perl code, which is even easier, than lua :slight_smile:

perl_set $anon_addr ’ sub {
use Digest::MD5 qw(md5_hex);
my $r = shift;
md5_hex $r->remote_addr
} ';

Thanks for the info. Is there a way to configure this globally for all
vhosts?

I have already this lines in my nginx.conf:
log_format combined_noip '127.0.0.1 - $remote_user [$time_local]

'“$request” $status $body_bytes_sent

‘“$http_referer”
“$http_user_agent”’;

So i would need the $anon_addr instead of the 127.0.0.1.

Thanks