-
-
Save qpfiffer/e8f936e567f44b8eb0e7 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
#!/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