Skip to content

Instantly share code, notes, and snippets.

@jamesbjackson
Created May 21, 2019 13:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamesbjackson/12ed5de4577018deb555e920c20c6385 to your computer and use it in GitHub Desktop.
Save jamesbjackson/12ed5de4577018deb555e920c20c6385 to your computer and use it in GitHub Desktop.
How to show current HTTP requests on any server

How to show current HTTP requests on any server

via https://dev.to/codeenigma/how-to-show-current-http-requests-on-any-server-mmp

"If you’re ever need to see incoming HTTP requests, maybe to check incoming headers, you want to know what cookies are being set, or get some clues as to why things aren’t being cached, the following command might be helpful:"

sudo tcpdump -A -s 10240 'tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)' | egrep --line-buffered "........(GET |HTTP\/|POST |HEAD )|[A-Za-z0-9-]+: " | sed -r 's/........(GET |HTTP\/|POST |HEAD )/\n\1/g'

"It’s a bit of a mouthful, but it shows incoming HTTP requests direct from the network interface, and formats them in a readable way for humans. The nice thing is that you can then use grep with the output to show things like incoming cookies, or request headers. Probably more useful for monitoring requests than watching log files and guessing."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment