server { listen 80; server_name _; root /usr/share/nginx/html; index index.html; # SPA fallback — all non-file requests go to index.html location / { try_files $uri $uri/ /index.html; } # Proxy API requests to the backend location /api { proxy_pass http://tenant-api:8080; 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 300s; proxy_send_timeout 300s; } # Proxy Swagger UI and OpenAPI JSON to the backend for API testing location ^~ /swagger { proxy_pass http://tenant-api:8080; 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 300s; proxy_send_timeout 300s; } # Cache static assets aggressively location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff2?)$ { expires 1y; add_header Cache-Control "public, immutable"; } gzip on; gzip_static on; gzip_vary on; gzip_types text/plain text/css application/json application/javascript text/xml; brotli_static on; }