Hello,
I think the reason for this issue is that your site has many products, etc. That takes a long time to read and write database and file.
You should try this: http://www.nginxtips.com/504-gateway-time-out-using-nginx/
You should check the system and exception log also => may find the root cause.
Problem solved? Click Accept as Solution!