Skip to content

Instantly share code, notes, and snippets.

@qpfiffer
Forked from nijotz/gist:1b541b07e7c5f34dc4f1
Created May 5, 2014 21:53
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 qpfiffer/e8f936e567f44b8eb0e7 to your computer and use it in GitHub Desktop.
Save qpfiffer/e8f936e567f44b8eb0e7 to your computer and use it in GitHub Desktop.
#!/bin/bash
if [ -z $1 ]
then
echo "Getting all nginx configs"
RESPONSE=$(grep server_name /etc/nginx/sites-enabled/* | sed -e 's/.*server_name //' -e 's/localhost *//' -e 's/ /\n/g' -e 's/;$//' | sed -re 's_^(.*)$_<li><a href="http://\1">\1</a></li>_')
else
echo $1
RESPONSE=$(grep server_name /etc/nginx/sites-enabled/$1 | sed -e 's/.*server_name //' -e 's/localhost *//' -e 's/ /\n/g' -e 's/;$//' | sed -re 's_^(.*)$_<li><a href="http://\1">\1</a></li>_')
fi
# Build our response
echo -e '<html><body><ul>'$RESPONSE'</ul></body></html>' > index.html;
python -m SimpleHTTPServer 9999 & sleep 1;
curl -i localhost:9999 > /tmp/index_headers.html 2>/dev/null;
kill %1;
# Serve forever
while true; do nc -l -p 6666 < /tmp/index_headers.html; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment