title: Cloudflare Bad Gateway 502 error
body: <p>Myself and my users are often running into a <code>Cloudflare Bad Gateway 502 error</code>. Trying to figure out what goes wrong is hard, because Cloudflare blames the hosting company and the hosting company blames Cloudflare. A typical situation when using Cloudflare.</p>
  
  <p>What I noticed is that nothing actually fails. The host receives the request and is handling the request just fine but which sometimes takes a bit longer than usual to complete. But Cloudflare can't wait and instead throws a <code>Bad Gateway</code> error, while the script is actually still running.</p>
  
  <p>I've noticed this behavior when performing heavy back-end tasks (like generating +50 PDFs). My users notice this when they try to upload an image (which often starts a re-sizing task).</p>
  
  <p>Is there a way I can configure my server so that Cloudflare knows that the request is still being processed? Or should I just ditch Cloudflare overall?</p>