Git Product home page Git Product logo

httpd-log-anon-filter's Introduction

httpd-log-anon-filter

about

httpd-log-anon-filter is an anonymizing log filter for httpd logs.

It is used to change the IP address/hostname field of webserver logs to something else than the original IP address/hostname in order to comply with German data privacy laws.

The project homepage is at https://github.com/mmitch/httpd-log-anon-filter

dependencies

  • Perl

usage

usage:
    httpd-log-anon-filter.pl <output_logfile>

httpd-log-anon-filter reads data in common or combined log format (in fact any data that has the IP address or hostname in the first whitespace delimited field on a line) from STDIN and appends the processed output to a filename given as the first and only commandline argument. Giving no output filename results in an error.

For every log line received, the IP address/hostname is hashed using MD5 and a new IP address (IPv6 for IPv6 input data, IPv4 for everything else) is generated. The new address replaces the old address/hostname and the new log line is written to the given filename.

On every startup, httpd-log-anon-filter generates a salt, so multiple invocations won't generate the same output for the same input. As long as httpd-log-anon-filter is not restarted, any given input address is always mapped to the same output address, so it is still possible to read logs in realtime and look for errors or follow some patterns.

On common system configurations (eg. Debian's default Apache installation), logs are rotated daily and thus the webserver is reloaded, which will also restart httpd-log-anon-filter and give you a new salt every day.

Beware that multiple instances of httpd-log-anon-filter will work with different salts, eg. when you have a non-SSL configuration and an SSL configuration both logging to the same file, they will possibly spawn two instances of httpd-log-anon-filter and the same source address will be mapped differently in the logs, depending on whether a http or https request was issued.

usage with Apache

Apache 2.4 supports piped logs. To use httpd-log-anon-filter, add a CustomLog statement like this:

CustomLog "|/path/to/httpd-log-anon-filter.pl /var/log/access_log" combined

This will write an anonymized log to the default log location /var/log/access_log. Apache automatically starts and stops httpd-log-anon-filter as needed, log rotation and maintenance should simply work as before.

customization

Currently, httpd-log-anon-filter can't really be customized. You can comment/uncomment some parts of the code:

  • IPv6 addresses are by default randomized completely. Most hashes will propably be non-existing addresses, but others will be real and your log will simply contain wrong information (well, that's the point in the first place). If for any reason you want to 'play nice', you can uncomment one of two other lines instead to either only generate addresses from 2001:db8::/32 (address range reserved for documentation purposes) or from 0100::/64 (discard).

  • IPv4 addresses are also completely randomized. Here the alternative is to use addresses from 10.0.0.0/8 (private address range), but that leaves you with only 24 random bits.

copyright

httpd-log-anon-filter - anonymizing log filter for httpd logs
Copyright (C) 2016 Christian Garbs [email protected]

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

httpd-log-anon-filter's People

Contributors

mmitch avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

iapx mars-83

httpd-log-anon-filter's Issues

Ignoring 127.0.0.1 and ::1

Really great tool, thank you for this! One nice little addition would be to be able to not anonymize local access, I guess it could also be used for any other hardcoded whitelisted IP.

Cheers!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.