Which timeout a 504 is actually asking for
A 504 usually triggers a proxy_read_timeout change. But 504s come from three places, and adjusting the wrong one only moves the problem.
proxy_connect_timeout covers nginx reaching upstream, 60s by default — fires when upstream is down or packets are dropped.
proxy_read_timeout is the maximum gap between reads once connected — fires when upstream is slow to send the first byte.
send_timeout covers nginx writing to a client that will not read.
The log names the culprit: upstream timed out ... while reading response header is the read timeout. Confirm upstream is genuinely slow with a direct curl before raising anything — usually a bigger timeout just makes a slower 504.