Cloudflare Bad Gateway 502错误
我自己和用户经常遇到 Cloudflare Bad Gateway 502错误
。试图找出问题所在是很难的,因为Cloudflare会责怪托管公司,而托管公司会责怪Cloudflare。使用Cloudflare时的典型情况。
Myself and my users are often running into a Cloudflare Bad Gateway 502 error
. 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.
我注意到的是,实际上没有任何故障。主机收到请求并正在处理请求,但有时完成时间会比平时更长。但是Cloudflare迫不及待地想在脚本实际上仍在运行时抛出 Bad Gateway
错误。
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 Bad Gateway
error, while the script is actually still running.
在执行繁重的后端任务(例如生成+50个PDF)时,我已经注意到这种行为。我的用户在尝试上传图像(通常会启动重新调整大小的任务)时注意到了这一点。
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).
有没有一种方法可以配置服务器,以便Cloudflare知道该请求仍在处理中?还是应该整体上放弃Cloudflare?
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?
罪魁祸首是Railgun。禁用Railgun(在Cloudflare的控制面板中)后, Bad Gateway 502
错误立即消失。
The culprit was Railgun. After disabling Railgun (in Cloudflare's control panel) the Bad Gateway 502
errors immediately disappeared.