504 Gateway Time-out media temple

I am constantly getting 504 gateway errors when my php script needs to
run
for longer than 60 secs.

I am on media temple on a dedicated server. I have contacted media
temple
and they have been helpful but none of their suggesion seem to work for
me i
was told to edit this file.

/etc/httpd/conf.d/fcgid.conf

which i have to below

LoadModule fcgid_module modules/mod_fcgid.so

<IfModule !mod_fastcgi.c>
AddHandler fcgid-script fcg fcgi fpl

FcgidIPCDir /var/run/mod_fcgid/sock
FcgidProcessTableFile /var/run/mod_fcgid/fcgid_shm
FcgidIdleTimeout 300
FcgidMaxRequestLen 1073741824
FcgidProcessLifeTime 10000
FcgidMaxProcesses 64
FcgidMaxProcessesPerClass 15
FcgidMinProcessesPerClass 0
FcgidConnectTimeout 600
FcgidIOTimeout 600
FcgidInitialEnv RAILS_ENV production
FcgidIdleScanInterval 600

so i have tried to max everything as much as i can, to test this i am just running the function below.

function test504(){
@set_time_limit(0);
sleep(60);
echo “true”;
}
Sleep will work on any value below 60 seconds returning true but on 60 i
get
504 gateway error.

my phpinfo(); outputs

max_execution_time 600
max_input_time 180
I have seen a few post on increasing this fastcgi_connect_timeout but
have
no idea where to find this on media temple.

Can anyone help thanks

UPDATE STILL CANT FIX THIS

after chatting with support i have been told i need to edit nginx.conf ?
and
was directed to this post

cant fine any of the values on my hosting. client_header_timeout
client_body_timeout send_timeout fastcgi_read_timeout

my nginx.conf file looks like this

#error_log /var/log/nginx/error.log info;

#pid /var/run/nginx.pid;

events {
worker_connections 1024;
}

http {
include mime.types;
default_type application/octet-stream;

#log_format  main  '$remote_addr - $remote_user [$time_local] 

“$request”

# '$status $body_bytes_sent “$http_referer” ’
# ‘“$http_user_agent” “$http_x_forwarded_for”’;

#access_log  /var/log/nginx/access.log  main;

sendfile        on;
#tcp_nopush     on;
#keepalive_timeout  0;
keepalive_timeout  120;
#tcp_nodelay        on;

#gzip  on;
#gzip_disable "MSIE [1-6]\.(?!.*SV1)";

server_tokens off;

include /etc/nginx/conf.d/*.conf;

}
This is driving me crazy any suggestions ???

Posted at Nginx Forum:

Hello!

On Tue, Oct 02, 2012 at 09:44:36AM -0400, samueleast wrote:

I am constantly getting 504 gateway errors when my php script needs to run
for longer than 60 secs.

Depending on module you use to pass request to backends, i.e.
proxy_pass or fastcgi_pass in your nginx config, you should tune
either proxy_read_timeout or fastcgi_read_timeout. Both defaults
to 60s. See here for more details:

http://nginx.org/r/proxy_read_timeout
http://nginx.org/r/fastcgi_read_timeout

[…]


Maxim D.

hi maxim thanks for the reply

i cant find out where these files and variables are on my hosting to
edit i
have checked all files in my nginx folder and i cant see those options
in
there anywhere.

will there just be a file with

proxy_pass
fastcgi_pass
proxy_read_timeout
fastcgi_read_timeout.

i tried editing the nginx.conf file to

http {
include mime.types;
default_type application/octet-stream;

#log_format  main  '$remote_addr - $remote_user [$time_local] 

“$request”

# '$status $body_bytes_sent “$http_referer” ’
# ‘“$http_user_agent” “$http_x_forwarded_for”’;

#access_log  /var/log/nginx/access.log  main;

sendfile        on;
#tcp_nopush     on;
#keepalive_timeout  0;
keepalive_timeout  120;
#tcp_nodelay        on;

#gzip  on;
#gzip_disable "MSIE [1-6]\.(?!.*SV1)";

server_tokens off;

server {
 location / {
  fastcgi_read_timeout 900s; # 15 minutes
 }
}
include /etc/nginx/conf.d/*.conf;

}

am i doing this correctly?

Posted at Nginx Forum:

Hello!

On Tue, Oct 02, 2012 at 10:56:58AM -0400, samueleast wrote:

proxy_read_timeout
# '$status $body_bytes_sent “$http_referer” ’
#gzip on;
}

am i doing this correctly?

The “include /etc/nginx/conf.d/*.conf;” in your config suggests
servers are configured somewhere in /etc/nginx/conf.d/.

The way you added fastcgi_read_timeout won’t work as it affects
only the server{} block you’ve added. You may try adding
fastcgi_read_timeout and/or proxy_read_timeout at http level
instead, i.e.

http {

fastcgi_read_timeout 900s;
proxy_read_timeout 900s;

include /etc/nginx/conf.d/*.conf;

}

This will work as long as they aren’t redefined in your server
configs in /etc/nginx/conf.d/.


Maxim D.

YOU ARE AMAZING this has been doing my head in for nearly to days i have
hounded media temple took about 20mins on this forum,

thank you so much :wink:

Posted at Nginx Forum:

samueleast Wrote:

YOU ARE AMAZING this has been doing my head in for nearly to days i
have hounded media temple took about 20mins on this forum,

thank you so much :wink:

Hey there! I’m glad you were able to get your issue resolved. I’m not
exactly sure what happened when you tried calling in to (mt) Media
Temple
but if the problem you call about is within our scope of support we will
always be able to help you. With that said, we are always happy to help
with
out of scope issues like this one, but it depends on whether or not the
agent is familiar with the issue you are calling about. I do apologize
that
you were unable to receive help on this when you called in. If you have
any
questions for us, we’re available 24/7 by phone, chat and Twitter.

Drew J
(mt) Media Temple
@MediaTemple

Posted at Nginx Forum:

Hi, I am also a Media Temple customer and its knowledgebase has not been
updated with this issue although it is very frequent from what I see.

Thank you very much.

I changed the nginx.conf file adding the lines you mentioned and then
restarted.

It also helped me a lot finding the nginx restart command on the blog
post
you mentioned:
kill -HUP ps -ef | grep nginx | grep master | awk {'print $2'}

Posted at Nginx Forum: