Skip to content

[Bug]: Uploads are very slow through the agent reverse proxy (ModSecurity scanning request bodies) #395

Description

@morepriyam

Current URL / affected service

A container I created through the Manager, running a Fastify app that does resumable (TUS) uploads. It's reached through the agent's nginx like any other service. https://pulsevault.os.mieweb.org/docs

For comparison, the same app runs on a plain EC2 box with nothing in front of it (https://pulse.morepriyam.com), and uploads there are fast.

Username

pmore

Version

main

Steps to reproduce

  1. Run an app that accepts large uploads (mine is Fastify + TUS) as a container, exposed as an HTTP service.
  2. Upload a big file (tens/hundreds of MB) — it goes up as large PATCH requests.
  3. Try the same upload straight to the app with no proxy in front, and compare the speed.

Expected behavior

Uploads through the platform proxy should be roughly as fast as hitting the app directly.

Actual behavior

They're much slower behind the proxy — bad enough to be unusable for bigger files. They don't fail, they just crawl.

I'm fairly sure it's the ModSecurity WAF on the agent. It's turned on globally in the nginx config and runs in DetectionOnly mode. Even in that mode it still reads the whole request body to scan it, so every upload chunk gets buffered and inspected before it reaches my container. That cancels out the proxy_request_buffering off that's already set, and since it's DetectionOnly it isn't even blocking anything, just logging — so I'm paying the scan cost for nothing.

A couple of other things in the generated config probably don't help big uploads either: the proxy timeouts are all hardcoded to 60s, and client_max_body_size is fixed at 2G.

Additional context

This has come up before — the WAF blocked PulseClip's TUS uploads in #219 (fixed by allowing the offset+octet-stream content type in #220), and it 403'd some HL7 traffic in #221, which is why it got moved to detection-only mode. So the pattern so far has been allowlisting specific cases rather than letting a service opt out.

Worth noting the error-pages server in the same config already uses modsecurity off, so turning it off per-server is possible. And #355 is currently reworking the same nginx template, so heads up on overlap.

Happy to help with a fix — I just wanted to raise it first and hear how you'd want to handle letting a service skip the WAF when it needs the upload speed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions