server { listen 80; root /usr/share/nginx/html; index index.html; # Proxy /api and /events to the kua-mail backend location ~ ^/(api|events)(/.*)?$ { proxy_pass https://api.mail.kua.cl; proxy_set_header Host api.mail.kua.cl; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_buffering off; proxy_read_timeout 600s; # SSE support proxy_http_version 1.1; proxy_set_header Connection ''; chunked_transfer_encoding on; } # SPA: all other routes → index.html location / { try_files $uri $uri/ /index.html; } gzip on; gzip_types text/plain text/css application/json application/javascript text/xml application/xml image/svg+xml; gzip_min_length 1024; }