Skip to content

Instantly share code, notes, and snippets.

@lcrilly
Last active April 21, 2020 14:58
Show Gist options
  • Save lcrilly/6916bb93f381989acc28040c46b9f9cb to your computer and use it in GitHub Desktop.
Save lcrilly/6916bb93f381989acc28040c46b9f9cb to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# get_server.sh (c) NGINX, Inc. [v0.3 10-Jul-2019] Liam Crilly <liam.crilly@nginx.com>
if [ $# -lt 1 ]; then
echo "USAGE: ${0##*/} [URI ...]"
exit 1
fi
for site in "$@"; do
echo -n "$site "
# Try server header
curl -I $site 2> /dev/null | grep -i ^server:
if [ $? -eq 1 ]; then
# Try 'get' behaviour
echo -n "Fingerprint: "
case `curl -siX get $site | head -1 | cut -f2 -d" "` in
"200" | "301" | "302")
echo "<CDN or BIG-IP>"
;;
"400")
echo "NGINX"
;;
"405")
echo "IIS"
;;
"501")
echo "Apache"
;;
*)
echo "<unknown>"
esac
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment