Skip to content

Instantly share code, notes, and snippets.

@gumblex
Last active June 4, 2022 21:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gumblex/8d54af5fcbf24b920b80 to your computer and use it in GitHub Desktop.
Save gumblex/8d54af5fcbf24b920b80 to your computer and use it in GitHub Desktop.
CGI script: Show visitor's IP and User Agent
#!/bin/bash
echo 'Status: 200 OK'
echo 'Content-Type: text/html; charset=utf-8'
echo
echo '<!DOCTYPE html>'
echo '<html><head>'
echo '<meta http-equiv="content-type" content="text/html; charset=UTF-8">'
echo '<meta name="description" content="'"$HTTP_USER_AGENT"'">'
# we use CloudFlare
echo "<title>$HTTP_CF_CONNECTING_IP</title>"
echo '</head><body>'
echo "<p>$HTTP_CF_CONNECTING_IP</p>"
echo "<p>$HTTP_USER_AGENT</p>"
echo "<p>$HTTP_REFERER</p>"
echo '</body></html>'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment