118 lines
3.5 KiB
Plaintext
118 lines
3.5 KiB
Plaintext
|
upstream ${UPSTREAM_NAME} {
|
||
|
server mastodon-web.${UPSTREAM_CNS_BASE_DOMAIN}:${UPSTREAM_PORT};
|
||
|
}
|
||
|
|
||
|
upstream streaming {
|
||
|
server mastodon-streaming.${UPSTREAM_CNS_BASE_DOMAIN}:4000 fail_timeout=0;
|
||
|
}
|
||
|
|
||
|
map $http_upgrade $connection_upgrade {
|
||
|
default upgrade;
|
||
|
'' close;
|
||
|
}
|
||
|
|
||
|
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=CACHE:10m inactive=7d max_size=1g;
|
||
|
|
||
|
# generated 2021-02-28, Mozilla Guideline v5.6, nginx 1.19, OpenSSL 1.1.1d, modern configuration
|
||
|
# https://ssl-config.mozilla.org/#server=nginx&version=1.19&config=modern&openssl=1.1.1d&guideline=5.6
|
||
|
server {
|
||
|
listen 80 default_server;
|
||
|
|
||
|
return 301 https://$host$request_uri;
|
||
|
}
|
||
|
|
||
|
server {
|
||
|
listen 443 ssl http2;
|
||
|
|
||
|
ssl_certificate /data/dehydrated/certs/${LETSENCRYPT_DOMAIN}/fullchain.pem;
|
||
|
ssl_certificate_key /data/dehydrated/certs/${LETSENCRYPT_DOMAIN}/privkey.pem;
|
||
|
ssl_session_timeout 1d;
|
||
|
ssl_session_cache shared:MozSSL:10m; # about 40000 sessions
|
||
|
ssl_session_tickets off;
|
||
|
|
||
|
# modern configuration
|
||
|
ssl_protocols TLSv1.3;
|
||
|
ssl_prefer_server_ciphers off;
|
||
|
|
||
|
# HSTS (ngx_http_headers_module is required) (63072000 seconds)
|
||
|
add_header Strict-Transport-Security "max-age=63072000" always;
|
||
|
|
||
|
# OCSP stapling
|
||
|
ssl_stapling on;
|
||
|
ssl_stapling_verify on;
|
||
|
|
||
|
# verify chain of trust of OCSP response using Root CA and Intermediate certs
|
||
|
ssl_trusted_certificate /data/dehydrated/certs/${LETSENCRYPT_DOMAIN}/fullchain.pem;
|
||
|
|
||
|
# replace with the IP address of your resolver
|
||
|
resolver 85.88.23.13 85.88.23.14 85.88.1.92;
|
||
|
|
||
|
keepalive_timeout 70;
|
||
|
sendfile on;
|
||
|
client_max_body_size 80m;
|
||
|
|
||
|
location /.well-known/keybase.txt {
|
||
|
root /var/www/html;
|
||
|
}
|
||
|
|
||
|
location / {
|
||
|
try_files $uri @proxy;
|
||
|
}
|
||
|
|
||
|
location ~ ^/(emoji|packs|system/accounts/avatars|system/media_attachments/files) {
|
||
|
add_header Cache-Control "public, max-age=31536000, immutable";
|
||
|
add_header Strict-Transport-Security "max-age=31536000";
|
||
|
try_files $uri @proxy;
|
||
|
}
|
||
|
|
||
|
location /sw.js {
|
||
|
add_header Cache-Control "public, max-age=0";
|
||
|
add_header Strict-Transport-Security "max-age=31536000";
|
||
|
try_files $uri @proxy;
|
||
|
}
|
||
|
|
||
|
location @proxy {
|
||
|
proxy_set_header Host $host;
|
||
|
proxy_set_header X-Real-IP $remote_addr;
|
||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||
|
proxy_set_header Proxy "";
|
||
|
proxy_pass_header Server;
|
||
|
|
||
|
proxy_pass http://${UPSTREAM_NAME};
|
||
|
proxy_buffering on;
|
||
|
proxy_redirect off;
|
||
|
proxy_http_version 1.1;
|
||
|
proxy_set_header Upgrade $http_upgrade;
|
||
|
proxy_set_header Connection $connection_upgrade;
|
||
|
|
||
|
proxy_cache CACHE;
|
||
|
proxy_cache_valid 200 7d;
|
||
|
proxy_cache_valid 410 24h;
|
||
|
proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
|
||
|
add_header X-Cached $upstream_cache_status;
|
||
|
add_header Strict-Transport-Security "max-age=31536000";
|
||
|
|
||
|
tcp_nodelay on;
|
||
|
}
|
||
|
|
||
|
location /api/v1/streaming {
|
||
|
proxy_set_header Host $host;
|
||
|
proxy_set_header X-Real-IP $remote_addr;
|
||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||
|
proxy_set_header Proxy "";
|
||
|
|
||
|
proxy_pass http://streaming;
|
||
|
proxy_buffering off;
|
||
|
proxy_redirect off;
|
||
|
proxy_http_version 1.1;
|
||
|
proxy_set_header Upgrade $http_upgrade;
|
||
|
proxy_set_header Connection $connection_upgrade;
|
||
|
|
||
|
tcp_nodelay on;
|
||
|
}
|
||
|
|
||
|
error_page 500 501 502 503 504 /500.html;
|
||
|
}
|