Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nginx error logs not masked #42

Closed
schroedingerkitten opened this issue Mar 5, 2020 · 1 comment · Fixed by #48
Closed

nginx error logs not masked #42

schroedingerkitten opened this issue Mar 5, 2020 · 1 comment · Fixed by #48

Comments

@schroedingerkitten
Copy link

I have trouble getting anonip to mask IPs in my nginx error.log file.

When I execute anonip as root, I receive the following error message:

# anonip < /var/log/nginx/error.log
WARNING:anonip:'2020' does not appear to be an IPv4 or IPv6 network
2020/03/05 19:27:43 [error] 1253#1253: *15347 open() "/usr/share/nginx/html/favicon.ico" failed (2: No such file or directory), client: XXX.XXX.XXX.XXX, server: address.tld, request: "GET /favicon.ico HTTP/1.1", host: "address.tld"

With XXX.XXX.XXX.XXX being some IP address (not masked) and address.tld the domain of the server.

I already tried the --delimiter and --column options:

# anonip --delimiter "," --column 2 < /var/log/nginx/error.log
WARNING:anonip:' client' does not appear to be an IPv4 or IPv6 network

Somehow I would need to tell anonip to look behind "client:", but that's not possible.

I thought anonip would work with error logs out of the box. Or have there been some recent changes in the way nginx is formating the error logs?

I am using nginx version nginx/1.14.0 (Ubuntu) and anonip 1.0.0 (installed through pip3).

@open-dynaMIX
Copy link
Member

For Anonip to work, the format of the log file needs to have the IP address at a predictable location. Unfortunately with nginx it's not possible to configure the format of the error-log AFAIK.

In your seconds example (anonip --delimiter "," --column 2), the string that's found is client: XXX.XXX.XXX.XXX. If the client: prefix is consistent, we could handle it. But it seems unreliable to me, because the error string comes before the IP address. If that error string contains a ,, detection of the IP address will fail.

open-dynaMIX added a commit to open-dynaMIX/Anonip that referenced this issue Dec 26, 2021
This commit implements regex based IP detection. This is intended to use
for logfiles where column based detection doesn't work.

See RFC (DigitaleGesellschaft#44) for more information.

Closes DigitaleGesellschaft#42, closes DigitaleGesellschaft#44
open-dynaMIX added a commit to open-dynaMIX/Anonip that referenced this issue Dec 26, 2021
This commit implements regex based IP detection. This is intended to use
for logfiles where column based detection doesn't work.

See RFC (DigitaleGesellschaft#44) for more information.

Closes DigitaleGesellschaft#42, closes DigitaleGesellschaft#44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants