Forum: NGINX 504 Gateway Time-out media temple

Posted by samueleast (Guest)
on 2012-10-02 15:45
(Received via mailing list)
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_fcgid.c>

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

  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

</IfModule>
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
http://blog.secaserver.com/2011/10/nginx-gateway-time-out/

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: 
http://forum.nginx.org/read.php?2,231318,231318#msg-231318
Posted by Maxim Dounin (Guest)
on 2012-10-02 16:06
(Received via mailing list)
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 Dounin
http://nginx.com/support.html
Posted by samueleast (Guest)
on 2012-10-02 16:57
(Received via mailing list)
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: 
http://forum.nginx.org/read.php?2,231318,231326#msg-231326
Posted by Maxim Dounin (Guest)
on 2012-10-02 17:12
(Received via mailing list)
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 Dounin
http://nginx.com/support.html
Posted by samueleast (Guest)
on 2012-10-02 17:24
(Received via mailing list)
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 ;)

Posted at Nginx Forum: 
http://forum.nginx.org/read.php?2,231318,231331#msg-231331
Posted by (mt) Drew (Guest)
on 2012-10-10 18:41
(Received via mailing list)
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 ;)


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: 
http://forum.nginx.org/read.php?2,231318,231592#msg-231592
Posted by nikandriko (Guest)
on 2013-04-30 23:50
(Received via mailing list)
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: 
http://forum.nginx.org/read.php?2,231318,238756#msg-238756
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.