# ============================================================================= # Nibula — nginx site configuration # ----------------------------------------------------------------------------- # Replace the three placeholders below, then follow the setup steps in # docs/Deploy.md → "Your own server (Nginx on a VPS)". # # YOUR_DOMAIN your domain — server_name, twice (port 80 and 443) # SITE_FOLDER the folder under /var/www/ holding the site # YOUR_CERTIFICATE the directory name under /etc/letsencrypt/live/ # ============================================================================= # HTTP (80) configuration server { server_name YOUR_DOMAIN; listen 80; listen [::]:80; # Webroot ACME renewal; drop if using the nginx authenticator. location ^~ /.well-known/acme-challenge/ { root /var/www/certbot; } location / { return 301 https://$host$request_uri; } } # HTTPS (443) configuration server { listen 443 ssl; listen [::]:443 ssl; # nginx >= 1.25; http2 on; server_name YOUR_DOMAIN; root /var/www/SITE_FOLDER; index index.html; # Certificate ssl_certificate /etc/letsencrypt/live/YOUR_CERTIFICATE/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/YOUR_CERTIFICATE/privkey.pem; include /etc/letsencrypt/options-ssl-nginx.conf; ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # Security headers add_header X-Content-Type-Options "nosniff" always; add_header X-Frame-Options "SAMEORIGIN" always; add_header Referrer-Policy "strict-origin-when-cross-origin" always; # HSTS persists in browsers for max-age even if removed here. Raise to # 31536000 once stable; "; includeSubDomains" needs HTTPS on all subdomains. add_header Strict-Transport-Security "max-age=300" always; # Hide Nginx version in error pages and Server HTTP header to avoid vulnerabilities server_tokens off; autoindex off; # Blocked paths (redirect to 404.html) error_page 403 404 /404.html; location ^~ /backend/ { return 404; } location ~* (^|/)web\.config$ { return 404; } location ~ /\. { return 404; } location ~ \.php$ { return 404; } # API backend — Node primary, PHP fallback location ^~ /api/ { proxy_pass http://127.0.0.1:3000; 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_read_timeout defaults to 60s; raise only for slow endpoints. proxy_connect_timeout 5s; proxy_intercept_errors on; error_page 502 504 = @php_backend; # WebSocket is not enabled; needs a $connection_upgrade map at http level. } location @php_backend { include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root/backend/core/index.php; fastcgi_pass unix:/run/php/php-fpm.sock; } # Static files location / { try_files $uri $uri/ $uri.html =404; } # Error page location = /404.html { internal; } }