Unix & Linux: How to monitor incoming http requests? (5 Solutions!!)
Channel: Roel Van de Paar
Date: 2020-08-10

Unix & Linux: How to monitor incoming http requests?


The Question: How can I monitor incoming HTTP requests to port 80? I have set up web hosting
on my local machine using DynDNS and Nginx. I wanted to know how many request
are made on my server every day.
Currently I'm using this command:
netstat -an | grep 80

Solutions: Please watch the whole video to see all solutions, in order of how many people found them helpful

== This solution helped 5 people ==
Do you have log files turned on for your server? If you do, I'd recommend
installing AwStats and running your log files with it to get accurate
reporting.
If you want to just monitor all incoming/outgoing traffic, you can use
WireShark.

== This solution helped 45 people ==
You may use tcpdump.
# tcpdump filter for HTTP GET
sudo tcpdump -s 0 -A 'tcp[((tcp[12:1] & 0xf0) ＞＞ 2):4] = 0x47455420'

# tcpdump filter for HTTP POST
sudo tcpdump -s 0 -A 'tcp dst port 80 and (tcp[((tcp[12:1] & 0xf0) ＞＞ 2):4] =
0x504f5354)'
For a solution using tshark see:
https://serverfault.com/questions/84750/monitoring-http-traffic-using-tcpdump

== This solution helped 4 people ==
You can also tail the log file:
tail -f /path/to/access_log
The -f parameter will cause tail to continually update the screen as new
entries are written to the log.

With thanks & praise to God, and with thanks to the many people who have made this project possible! | Content (except music & images) licensed under cc by-sa 3.0 | Music: https://www.bensound.com/royalty-free-music | Images: https://stocksnap.io/license & others | With thanks to user vsingh (https://unix.stackexchange.com/users/108706), user user7044 (https://unix.stackexchange.com/users/10143), user prayagupd (https://unix.stackexchange.com/users/17781), user nad (https://unix.stackexchange.com/users/10146), user djsumdog (https://unix.stackexchange.com/users/9935), user Dave (https://unix.stackexchange.com/users/10148), and the Stack Exchange Network (http://unix.stackexchange.com/questions/19485). Trademarks are property of their respective owners. Disclaimer: All information is provided "AS IS" without warranty of any kind. You are responsible for your own actions. Please contact me if anything is amiss at Roel D.OT VandePaar A.T gmail.com.