# nginx SPA (Single Page Application) hosting configuration
# Generated by RDT (Rambo Docker Tools)
# Place your built SPA files in: {{ nginx_html_dir | default('./nginx/html') }}
# To customise, edit this file and run `rdt add nginx-spa` again (existing files are not overwritten).

worker_processes auto;

events {
    worker_connections 1024;
}

http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    sendfile        on;
    keepalive_timeout  65;

    # Gzip
    gzip on;
    gzip_types text/plain text/css application/json application/javascript text/xml application/xml image/svg+xml;
    gzip_vary on;

    server {
        listen 80;
        server_name {{ nginx_server_name | default('localhost') }};

        root   /usr/share/nginx/html;
        index  index.html;

        # Cache static assets aggressively
        location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
            expires 1y;
            add_header Cache-Control "public, immutable";
        }

        # SPA fallback — all routes serve index.html
        location / {
            try_files $uri $uri/ /index.html;
        }
    }
}

