4

I tried the suggestions at:

How do I prevent a Gateway Timeout with FastCGI on Nginx

nginx.conf (inside of http section {})

#prevent gateway timeout
client_header_timeout 1000000;
client_body_timeout 1000000;
send_timeout 1000000;
fastcgi_read_timeout 1000000;

But after about 60 seconds I get an error 504 gateway timeout. We have nginxx in front of apache, so I am not sure if apache is causing the error, but we get a 504 gateway timeout that is clearly from nginx

Community
  • 1
  • 1
Chris Muench
  • 17,444
  • 70
  • 209
  • 362

1 Answers1

11

The definition of the 504 HTTP response code says: "The server was acting as a gateway or proxy and did not receive a timely response from the upstream server." So, it makes sense to start by treating this an issue with the backend server.

You should check what happens you make a request directly to the backend server. How long does it take to respond?

Note that with Apache you can configure your logs to include the time to taken to process the request. See the %t and %T options for mod_log_config.

If Nginx can access the backend server, so can you from the command line. Here's an example syntax to execute and time a request:

time -p GET -H 'Host: publicname.com'  http://127.0.0.1:8080/path/to/request

The "GET" tool is part of the libwww-perl package available on Ubuntu-like Linux distributions. By sending a "Host:" header, you are generating a request much like Nginx would.

Mark Stosberg
  • 12,961
  • 6
  • 44
  • 49
  • I can't make direct access to the server because wordpress can't work if you use a port number. But we have another site on the server that I can access using a port number and it never times out. It only times out when using NGINX. – Chris Muench Feb 27 '13 at 16:44
  • 2
    I updated my answer to detail how to simulate a request in the same mannner that Nginx would make. – Mark Stosberg Feb 27 '13 at 19:40