# ============================================================ # Swirl Master — Nginx Configuration # Reverse proxy voor de Flask API + statische bestanden # ============================================================ # Plaats in: /etc/nginx/sites-available/swirl # Symlink: ln -s /etc/nginx/sites-available/swirl /etc/nginx/sites-enabled/swirl # Test: nginx -t # Reload: systemctl reload nginx server { listen 80; listen [::]:80; server_name swirl.mescalinerabbit.shop; # Redirect naar HTTPS return 301 https://$host$request_uri; } server { listen 443 ssl http2; listen [::]:443 ssl http2; server_name swirl.mescalinerabbit.shop; # SSL certificaten (pas paden aan indien nodig) ssl_certificate /etc/letsencrypt/live/mescalinerabbit.shop/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/mescalinerabbit.shop/privkey.pem; # SSL instellingen ssl_protocols TLSv1.2 TLSv1.3; ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256; ssl_prefer_server_ciphers off; ssl_session_cache shared:SSL:10m; ssl_session_timeout 1d; # Security headers add_header X-Frame-Options "SAMEORIGIN" always; add_header X-Content-Type-Options "nosniff" always; add_header X-XSS-Protection "1; mode=block" always; add_header Referrer-Policy "strict-origin-when-cross-origin" always; add_header Strict-Transport-Security "max-age=63072000; includeSubDomains" always; # Gzip compressie gzip on; gzip_vary on; gzip_min_length 1024; gzip_proxied any; gzip_comp_level 6; gzip_types text/plain text/css text/xml text/javascript application/json application/javascript application/xml application/xml+rss font/woff2; # Statische bestanden — direct door Nginx (snel!) location / { root /root/projects/jg/2026-ninja-swirl-recipes/deliverables; index index.html; try_files $uri $uri/ @api; # Cache statische assets location ~* \.(css|js|jpg|jpeg|png|gif|ico|svg|woff|woff2|ttf|eot)$ { root /root/projects/jg/2026-ninja-swirl-recipes/deliverables; expires 30d; add_header Cache-Control "public, immutable"; } } # API proxy naar Flask location @api { proxy_pass http://127.0.0.1:5060; proxy_http_version 1.1; 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_connect_timeout 10s; proxy_read_timeout 30s; } # API endpoints location /api/ { proxy_pass http://127.0.0.1:5060; proxy_http_version 1.1; 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_connect_timeout 10s; proxy_read_timeout 30s; # Rate limiting (optioneel) limit_req zone=api burst=20 nodelay; } # Health check (geen rate limit) location = /api/health { proxy_pass http://127.0.0.1:5060; access_log off; } # Favicon location = /favicon.ico { root /root/projects/jg/2026-ninja-swirl-recipes/deliverables; log_not_found off; } # Robots location = /robots.txt { return 200 "User-agent: *\nAllow: /\n"; add_header Content-Type text/plain; } # Error pages error_page 404 /404.html; error_page 500 502 503 504 /50x.html; # File upload limit (voor toekomstige foto upload) client_max_body_size 10M; # Access log access_log /var/log/nginx/swirl-master-access.log; error_log /var/log/nginx/swirl-master-error.log; } # ============================================================ # Rate limiting zone (voeg toe aan http {} block in nginx.conf): # limit_req_zone $binary_remote_addr zone=api:10m rate=10r/s; # ============================================================