Over the last few days, I’ve been looking at Apache web server logs, a lot, mostly quick checks for Shellshock probes and exploit attempts. All on client servers, thankfully. All of the servers I operate through DigitalOcean are patched up. It just so happens that all the sites I host have their DNS hosted by Cloudflare, which has been blocking all Shellshock attempts.
A majority of my sites send their Apache logs to Papertrail. Having all my apache logs easily accessible and searchable is extremely nice. It’d make sniffing out Shellshock attempts quite simple. You can check for Shellshock attempts relatively easily from the command line, as well, something like the command below would work:
grep '() {' /var/log/apache2/access.log
1. Setup Rsyslog to Send to Papertrail
Anyway, sending Apache logs to Papertrail is pretty easy. I’m going to assume you’ve already setup rsyslog to send logs to Papertrail. If not, this post should help.
2. Add CustomLog Directive To Your VirtualHost
You just need to modify your virtualhost configuration and add a CustomLog directive. Here’s what I do to send longren.io logs to Papertrail:
CustomLog "| /usr/bin/logger -t httpd -p local1.info" "%{%b %d %X}t longren.io apache %h %l %u %t "%r"%>s %b "%{Referer}i" "%{User-agent}i""
The -t httpd
piece sets the service name for Papertrail. The -p local1.info
flag sets the priority. You’ll want to change the longren.io
piece in the above code to whatever site you’re capturing logs for. You can also change or remove apache
that immediately follows longren.io.
3. Reload Apache
After you’ve added the CustomLog directive to your virtualhost, you’ll want to reload Apache:
sudo service apache reload
That’s all there is to it. You should start seeing your Apache logs in Papertrail shortly after reloading Apache.