Skip to content

Instantly share code, notes, and snippets.

@patrolez
Last active October 14, 2024 18:01
Show Gist options
  • Save patrolez/15d4c9ac2673ed6e7793cf29960aed82 to your computer and use it in GitHub Desktop.
Save patrolez/15d4c9ac2673ed6e7793cf29960aed82 to your computer and use it in GitHub Desktop.

Handy static Nginx in docker HTTP one-liner Web Server files hosting with Directory Listing of $PWD

It has autoindex on specified by default.

Can be accessed via HTTP with port 8000, should be bound to the 0.0.0.0 IP address.

docker run --rm -it -p 8000:80 -v $PWD:/mnt/data nginx /bin/bash -c "echo $'server {\nlisten 80;\nserver_tokens off;\n\nlocation / {\nalias /mnt/data/;\nexpires -1;\nautoindex on;\ndefault_type text/plain;\n}\n}' > /etc/nginx/conf.d/default.conf; nginx -g 'daemon off;'"

Handy HTTP Web Server addresses display one-liner

ip addr show | grep inet | grep -v inet6 | cut -d'/' -f1 | awk '{print "http://"$2":8000"}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment