https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.5.5
10.5.5 504 Gateway Timeout
The server, while acting as a gateway or proxy, did not receive a timely response from the upstream server specified by the URI (e.g. HTTP, FTP, LDAP) or some other auxiliary server (e.g. DNS) it needed to access in attempting to complete the request.
Note: Note to implementors: some deployed proxies are known to return 400 or 500 when DNS lookups time out.
A 504 Gateway Timeout error typically indicates a server-side problem. ie your Gateway or Proxy Server is not processing something correctly and the Request times out. To see if anything in BPS is related to the problem do the standard BPS troubleshooting steps: http://forum.ait-pro.com/forums/topic/read-me-first-free/#bps-free-general-troubleshooting and check your BPS Security Log for log entries. Hopefully you are not logging into your website using a Free Proxy since your login credentials can be easily captured by a Free Proxy. Free Proxies are good for visiting websites or browsing when you do not want to expose your Public IP address.
Other Related Forum Topics
http://forum.ait-pro.com/forums/topic/504-gateway-timeout-504-error/
http://forum.ait-pro.com/forums/topic/php-info-and-php-error-log-not-visible/