Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/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
You can’t perform that action at this time.