My personal nginx configuration for sharing files
# Copyright 2020 Google LLC. | |
# SPDX-License-Identifier: Apache-2.0 | |
worker_processes 4; | |
events { | |
use epoll; | |
} | |
http { | |
sendfile on; | |
aio on; | |
directio 4m; | |
tcp_nodelay on; | |
tcp_nopush on; | |
limit_conn_zone $binary_remote_addr zone=conn_limit_per_ip:10m; | |
limit_req_zone $binary_remote_addr zone=req_limit_per_ip:10m rate=5r/s; | |
include /etc/nginx/mime.types; | |
default_type application/octet-stream; | |
# Signal to the CDN that the content can be cached forever. | |
expires max; | |
# External view for serving files, proxied through cloudflare | |
server { | |
listen 8080; | |
root /www/data; | |
limit_conn conn_limit_per_ip 10; | |
limit_req zone=req_limit_per_ip burst=10 nodelay; | |
location / { | |
} | |
} | |
# Internal view for listing files, only available inside the network | |
server { | |
listen 8088; | |
root /www/data; | |
# Print listings for directories (and subdirectories) | |
location ~ /$ { | |
autoindex on; | |
} | |
# Redirect everything else to cloudflare | |
location / { | |
return 301 https://files.brian-gordon.net$request_uri; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment