Skip to content

Instantly share code, notes, and snippets.

@asterite3
Created March 6, 2019 16:43
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 asterite3/4b9159b8bfcdf9ad8def88168d28b60e to your computer and use it in GitHub Desktop.
Save asterite3/4b9159b8bfcdf9ad8def88168d28b60e to your computer and use it in GitHub Desktop.
Bash one-liner to run nginx on command line as regular user to serve files from current directory (a replacement for python -m SimpleHTTPServer)
T=`mktemp` P=`mktemp` && bash -e -c "exec 3<$T && exec 4>$P && rm $P && echo -e 'daemon off;worker_processes auto;pid /dev/null;error_log /dev/stderr;events {} http { access_log /dev/stdout; include /etc/nginx/mime.types; server { listen 127.0.0.1:8000; location / { autoindex on; autoindex_exact_size off; root .;} }}' > $T && rm $T && exec nginx -p . -c /dev/fd/3"
@asterite3
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment