Skip to content

Instantly share code, notes, and snippets.

@jkvim
Last active August 21, 2017 03:41
Show Gist options
  • Save jkvim/078c765175dcd563eedff5e66aa07ad4 to your computer and use it in GitHub Desktop.
Save jkvim/078c765175dcd563eedff5e66aa07ad4 to your computer and use it in GitHub Desktop.
Nginx static file server
server {
client_max_body_size 4G;
listen 80;
server_name localhost;
root /path/to/fileServer; # your folder to serve
location / {
types {
application/octet-stream txt; # specify which type force to download instead of open
}
auth_basic "Restricted";
auth_basic_user_file /usr/local/etc/nginx/pass_file; # create password by `htpasswd -c -d /etc/nginx/pass_file username`
autoindex on; # generate index
autoindex_exact_size on; # show filesize
autoindex_localtime on; # show time
sendfile on;
sendfile_max_chunk 1m;
tcp_nodelay on;
keepalive_timeout 65;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment