Skip to content

Instantly share code, notes, and snippets.

@gumblex gumblex/ip.sh

Last active Mar 1, 2016
Embed
What would you like to do?
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
You can’t perform that action at this time.