fail_timeout = 0; in the upstream, NGINX relies on
proxy_connect_timeout also, which is set to a default of 60s, and according to their documentation, can not generally exceed 75s.
proxy_connect_timeout is not set (and it's not in that guide), it defaults to 60s. If you're app isn't responding in that amount of time, you'll receive a 504 GTO error.
What this means is that when NGINX proxies the request to your app, it's just not responding quickly enough with a valid response (i.e. 200 or other), so to resolve this, you'd need to take a look at your application and see why it's not responding.
I've tested quit a few of the stock one-click images and they work as intended (the test app works), so I don't think it's an issue there, but most likely something within the app you've installed and are trying to poxy requests to.