Files
vitfit-r2/V2/deploy/nginx/vitfit.conf
T
2026-06-13 08:03:45 -04:00

92 lines
4.1 KiB
Plaintext

# VitFit — Nginx reverse proxy
# Replace 'your.domain.com' with your actual domain before deploying.
#
# TLS mode — only one block should be active at a time:
# Option A (Let's Encrypt via certbot) → lines marked [LE] — ACTIVE by default
# Option B (custom / uploaded cert) → lines marked [CUSTOM] — commented out
#
# To switch to Option B:
# 1. Comment out all [LE] lines
# 2. Uncomment all [CUSTOM] lines
# 3. Copy your cert to /etc/nginx/ssl/vitfit.crt and key to /etc/nginx/ssl/vitfit.key
# 4. nginx -t && nginx -s reload
# ── HTTP: ACME challenge pass-through + redirect ───────────────────────────────
server {
listen 80;
listen [::]:80;
server_name your.domain.com;
# [LE] certbot HTTP-01 challenge files
location /.well-known/acme-challenge/ {
root /var/www/certbot;
}
location / {
return 301 https://$host$request_uri;
}
}
# ── HTTPS ──────────────────────────────────────────────────────────────────────
server {
listen 443 ssl;
listen [::]:443 ssl;
http2 on;
server_name your.domain.com;
# ── [LE] Let's Encrypt certificate (managed by certbot) ───────────────────
ssl_certificate /etc/letsencrypt/live/your.domain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/your.domain.com/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
# ── [CUSTOM] Uploaded / self-signed certificate ───────────────────────────
# ssl_certificate /etc/nginx/ssl/vitfit.crt;
# ssl_certificate_key /etc/nginx/ssl/vitfit.key;
# 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;
# ssl_prefer_server_ciphers off;
# ssl_session_cache shared:SSL:10m;
# ssl_session_timeout 1d;
# ── Security headers ──────────────────────────────────────────────────────
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;
add_header X-Frame-Options SAMEORIGIN always;
add_header X-Content-Type-Options nosniff always;
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
# ── Video upload size — match UPLOAD_MAX_BYTES in .env ───────────────────
client_max_body_size 2100m;
# ── Proxy to Node app ─────────────────────────────────────────────────────
location / {
proxy_pass http://127.0.0.1:3000;
proxy_http_version 1.1;
# WebSocket upgrade (required for socket.io)
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
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;
# Long timeouts keep socket.io connections alive through the proxy
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
# Disable buffering for streaming video responses (Range requests)
proxy_buffering off;
}
}
# ── WebSocket connection upgrade map ──────────────────────────────────────────
# Place this in the http{} block of your nginx.conf (not inside server{}).
# If you're using a separate conf.d include, add a map-only file instead.
#
# map $http_upgrade $connection_upgrade {
# default upgrade;
# '' close;
# }