Another HTH ...
check logs for a reference to a 'checknet.txt' file request ... SCORM's are an application shipped to client and run from client machine. Those could be large and involved taking quite a lot of time to do whatever is in them. Maybe over the session limit setting. Like a ping back to Moodle saying, 'hey, am running SCORM and I'm still here!'. If the checknet ping doesn't get to moodle, one might see the 504 gateway error.
Once got the advice from the person who, at the time, maintained SCORM for Moodle (or so I was told), to make the SCORM's smaller or break them apart into smaller 2 part things. Probably would have worked, but the authors of the content rejected the suggestion. Nearly all of their courses were 100% SCORM - site was a large site with load balancer etc. (just to give you an idea of size/usage). Eventually, because this issue didn't appear to be resolveable, entity moved to Canvas. Moodle lost a chunk of 'market share' as a result because the entity was followed by other smaller entities ... 'whatever the Joneses' did', kinda thing.
Or, like Videos, host the larger/longer SCORM's else where and use moodle as a portal to them.
https://rusticisoftware.com/products/rustici-dispatch/
which won't be free hosting, of course. Never tried that myself, soooooo ?????
Anyhoo ...
HTH also.
'SoS', Ken