server {
    listen 80;
    listen [::]:80;
    server_name __DOMAIN_APP__;

    # Allow audio file uploads up to ~1.86 GB (matches the per-request ceiling on api/track/upload
    # and api/track/{id}/replace-audio). nginx default is 1 MB, which would 413 any large upload.
    client_max_body_size 2000m;

    location / {
        proxy_pass         http://localhost:__PORT_MANAGER__;
        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;

        # WebSocket support (Blazor InteractiveServer SignalR circuits)
        proxy_set_header Upgrade    $http_upgrade;
        proxy_set_header Connection $http_connection;

        # Large audio uploads stream over the SignalR WebSocket circuit for several minutes.
        # nginx's 60 s default would drop the connection mid-transfer and silently kill the
        # Blazor circuit — the app never sees an error, so nothing is logged. 1200 s matches
        # the Upload:ResponseTimeoutSeconds budget already configured in the application.
        proxy_read_timeout 1200s;
        proxy_send_timeout 1200s;
    }
}
