Skip to content

Instantly share code, notes, and snippets.

@ivan-kleshnin
Last active August 29, 2015 14:10
Show Gist options
  • Save ivan-kleshnin/6fd48873eba25f2c3ac5 to your computer and use it in GitHub Desktop.
Save ivan-kleshnin/6fd48873eba25f2c3ac5 to your computer and use it in GitHub Desktop.
How to reveal hackers and spammers in standard nginx logs (OS X instruction)
# put this file in home folder
date_format %d/%b/%Y
log_format %h %^[%d:%^] "%r" %s %b "%R" "%u"
1) brew install goaccess
2) cd to logs folder
3) gunzip -c nginx.* | goaccess -p ~/.goaccessrc # does not work without explicit path to config (bug!)
select [5-hosts], enter and see most active hosts (bots, scanners, etc.)
4) gunzip -c nginx.access* | awk '($9 ~ /404/)' | cut -d " " -f 1,6,7,8 | uniq | less
see and analyze 404 errors manually
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment