Last active
April 21, 2020 14:58
-
-
Save lcrilly/6916bb93f381989acc28040c46b9f9cb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# get_server.sh (c) NGINX, Inc. [v0.3 10-Jul-2019] Liam Crilly <[email protected]> | |
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