I thought that some of you would like to see this:
Originally Posted by ta_devops
Root cause: A shared PHP include was sending output before vBulletin’s attachment.php could set headers. Specifically, the file ended with a closing PHP tag ?> and a trailing newline, which emits a byte.
Why it broke (especially via Cloudflare): With HTTP/2 to origin enabled, Cloudflare expects clean, correctly framed responses. That stray output forced default headers (text/html + chunked), so the binary attachment stream no longer matched expectations and Cloudflare returned 502 on GET requests.
The fix: Removed the trailing ?> (and any whitespace) at the end of the culprit PHP files so they can’t output early. Turned compression off for attachment.php at the origin (Apache + PHP) to ensure stable Content-Length for streamed files.
Result: Attachments download normally again, even with HTTP/2 to origin on.
Best practice going forward: we shouldn't use ?> at the end of PHP-only files, we should avoid any echo/print/whitespace in includes that run before file downloads, and we should exclude download endpoints from origin/edge compression.