-
-
Save prantlf/a30e1c94b395ecf97ff6164d3d8179d6 to your computer and use it in GitHub Desktop.
Serve current directory via nginx
This file contains 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
# Simple development setup to serve a directory at http://localhost:9001. | |
# Start nginx in the directory to serve with `nginx -c ~/nginx.conf`. | |
# When using a laptop with an above average equipment. 2 workers | |
# significantly increase the throughput. 4 workers still help | |
# noticeably. The server slows down With more than 6 workers. | |
worker_processes 2; | |
events { | |
accept_mutex off; | |
} | |
# Run as a foreground process and print errors on the console. | |
daemon off; | |
error_log stderr; | |
http { | |
# Serve files with correct mimetypes on OSX. The location may have to | |
# be adjusted depending on your OS and nginx installation. | |
include /usr/local/etc/nginx/mime.types; | |
# Improve the speed of processing requests, even a little. | |
access_log off; | |
# Optimise serving lots of static files in a quick pace. Share buffers | |
# betweek kernel and user spaces. Utilise the full TCP packet length. | |
sendfile on; | |
sendfile_max_chunk 1m; | |
tcp_nopush on; | |
tcp_nodelay on; | |
server { | |
# Serve the content at http://localhost:9001. | |
server_name localhost; | |
listen 9001; | |
# Serve files from the current directory and its descenadants. | |
root .; | |
# Generate directory listings for paths ending with /. | |
autoindex on; | |
# Enable the HTTP response compression. | |
gzip on; | |
# Prevent the browser from fetching the content again if the page reloads | |
# very quickly. 5s should be short enough for switching to an editor, | |
# saving a change, switching back to the browser and reloading the page. | |
expires 5; | |
# Do not compute file content or state hashes. The last modification time | |
# with the usual file system precision 2s should be enough to support | |
# the content validation. | |
etag off; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment