r2
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
#!/usr/bin/env bash
|
||||
# Renew Let's Encrypt certificates and reload nginx only when a cert was renewed.
|
||||
# Run via cron or systemd timer twice daily (certbot skips certs with >30 days left).
|
||||
#
|
||||
# Recommended cron entry (as root):
|
||||
# 0 3,15 * * * /path/to/vitfit/deploy/nginx/certbot-renew.sh >> /var/log/certbot-renew.log 2>&1
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
certbot renew --quiet --deploy-hook "nginx -s reload"
|
||||
@@ -0,0 +1,8 @@
|
||||
# Add this block to the http{} section of your main nginx.conf
|
||||
# (typically /etc/nginx/nginx.conf), NOT inside vitfit.conf.
|
||||
# It enables WebSocket upgrade pass-through for socket.io.
|
||||
|
||||
map $http_upgrade $connection_upgrade {
|
||||
default upgrade;
|
||||
'' close;
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
# 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;
|
||||
# }
|
||||
Reference in New Issue
Block a user