Last active
March 11, 2021 04:54
-
-
Save briangordon/1997e860f4228f02fe9e7fae51f3ccbe to your computer and use it in GitHub Desktop.
My personal nginx configuration for sharing files
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
user www-data; | |
worker_processes auto; | |
pid /run/nginx.pid; | |
include /etc/nginx/modules-enabled/*.conf; | |
events { | |
worker_connections 768; | |
# multi_accept on; | |
# Mine. Probably not necessary but why not | |
use epoll; | |
} | |
http { | |
## | |
# Basic Settings | |
## | |
sendfile on; | |
tcp_nopush on; | |
tcp_nodelay on; | |
keepalive_timeout 65; | |
types_hash_max_size 2048; | |
# server_tokens off; | |
# server_names_hash_bucket_size 64; | |
# server_name_in_redirect off; | |
include /etc/nginx/mime.types; | |
default_type application/octet-stream; | |
## | |
# SSL Settings | |
## | |
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE | |
ssl_prefer_server_ciphers on; | |
## | |
# Logging Settings | |
## | |
access_log /var/log/nginx/access.log; | |
error_log /var/log/nginx/error.log; | |
## | |
# Gzip Settings | |
## | |
gzip on; | |
# gzip_vary on; | |
# gzip_proxied any; | |
# gzip_comp_level 6; | |
# gzip_buffers 16 8k; | |
# gzip_http_version 1.1; | |
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; | |
## | |
# Virtual Host Configs | |
## | |
include /etc/nginx/conf.d/*.conf; | |
include /etc/nginx/sites-enabled/*; | |
############################################################################# | |
# My customizations below here. | |
############################################################################# | |
# O_DIRECT for large files (no kernel level caching) | |
directio 10m; | |
# Ratelimiting | |
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; | |
# Redirect to secure | |
server { | |
listen 80 default_server; | |
return 301 https://$host$request_uri; | |
} | |
# Main secure server config | |
server { | |
listen 443 ssl http2; | |
root /var/www; | |
limit_conn conn_limit_per_ip 10; | |
limit_req zone=req_limit_per_ip burst=10 nodelay; | |
# SSL (generated by ssl-config.mozilla.org at intermediate) | |
server_name ludi.brian-gordon.net; | |
ssl_certificate /etc/letsencrypt/live/ludi.brian-gordon.net/fullchain.pem; | |
ssl_certificate_key /etc/letsencrypt/live/ludi.brian-gordon.net/privkey.pem; | |
ssl_session_timeout 1d; | |
ssl_session_cache shared:MozSSL:10m; # about 40000 sessions | |
ssl_session_tickets off; | |
ssl_dhparam /etc/nginx/dhparam; | |
ssl_protocols TLSv1.2 TLSv1.3; | |
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384; | |
ssl_prefer_server_ciphers off; | |
gzip off; # See http://breachattack.com/ | |
#add_header Strict-Transport-Security "max-age=63072000" always; | |
# Flood | |
location /flood/api { | |
proxy_pass http://127.0.0.1:3000; | |
proxy_buffering off; | |
proxy_cache off; | |
include /etc/nginx/auth.conf; | |
} | |
location /flood/ { | |
alias /usr/lib/node_modules/flood/dist/assets/; | |
try_files $uri /flood/index.html; | |
include /etc/nginx/auth.conf; | |
} | |
location /flood { | |
return 301 /flood/; | |
} | |
location /files { | |
return 301 /files/; | |
} | |
location /files/ { | |
} | |
location /favicon.ico { | |
} | |
location / { | |
return 403; | |
} | |
} | |
} |
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
# 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