Last active
August 21, 2017 03:41
-
-
Save jkvim/078c765175dcd563eedff5e66aa07ad4 to your computer and use it in GitHub Desktop.
Nginx static file server
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
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