The httpry utility is a lightweight packet inspector/analyzer specifically used to look at HTTP requests. It displays packet source and destination along with a request (GET, POST, PATCH, PUT) and the path followed by the response code, and other data going in the other direction.
httpry is available in the EPEL repo, and is easy to install with yum.
yum -y install httpry
To print HTTP requests to the console, simply use httpry with no arguments. It will automatically use the default interface and print packets to the screen.
Output looks like this:
2014-12-06 11:01:16 18.104.22.168 22.214.171.124 > GET centoshowtos.org / HTTP/1.1 - -
2014-12-06 11:01:16 126.96.36.199 188.8.131.52 < - - - HTTP/1.1 200 OK
Sometimes it makes sense to let httpry run in the background as a daemon and log to a file for later parsing/analysis. To do this, we add the -d flag, and specify an output file with -o.
httpry -d -o /tmp/httpry_log-`date +%Y%m%d`.out
If you want to monitor a different interface than the default (say eth1), you just add the -i flag with the interface name.
httpry -i eth1
If you run as a daemon, and create a pidfile, you can use logrotate to rotate the log, and restart by sending a SIGHUP to the pid postrotate.
httpry -o /var/log/httpry.log -P /var/run/httpry.pid -d -F -u httpryuser
logrotate might look something like
create 644 motorrobot motorrobot
[ -f /var/run/httpry.pid ] && kill -HUP `cat /var/run/httpry.pid`