zoukankan      html  css  js  c++  java
  • 504 Gateway Time-out nginx/1.15.5 如何解决?

    可能的错误原因:

    nginx访问出现504 Gateway Time-out,一般是由于程序执行时间过长导致响应超时,例如程序需要执行120秒,而nginx最大响应等待时间为60秒,这样就会出现超时。

    通常有以下几种情况导致:

    1.程序在处理大量数据,导致等待超时。

    2.程序中调用外部请求,而外部请求响应超时。

    3.连接数据库失败而没有停止,死循环重新连。

     

    解决办法:

    nginx配置

    nginx.conf中,设置以下几个参数,增加超时时间

    fastcgi_connect_timeout
    fastcgi连接超时时间,默认60秒

    fastcgi_send_timeout
    nginx 进程向 fastcgi 进程发送请求过程的超时时间,默认值60秒

    fastcgi_read_timeout
    fastcgi 进程向 nginx 进程发送输出过程的超时时间,默认值60秒


    php配置

    php.ini

    max_execution_time

    php脚本最大执行时间

     

    php-fpm

    request_terminate_timeout

    设置单个请求的超时时间

    php程序中可加入set_time_limit(seconds)设置最长执行时间。例如 set_time_limit(0) 表示不超时。

     

     

    504 Gateway Timeout error using Nginx as Proxy

    For Nginx as Proxy for Apache web server, this is what you have to try to fix the 504 Gateway Timeout error:

    Add these variables to nginx.conf file:

    proxy_connect_timeout 600;

    proxy_send_timeout 600;

    proxy_read_timeout 600;

    send_timeout 600;

    Then restart nginx:

    service nginx reload

     

    另外一种可能是请求的数据量过大,需要调整buffer大小

    proxy_connect_timeout 1;

    proxy_send_timeout 300;

    proxy_read_timeout 300;

    proxy_buffer_size 1M;

    proxy_buffers 8 1M;

    proxy_busy_buffers_size 1M;

    proxy_temp_file_write_size 1M;

     

    文章来源:刘俊涛的博客 欢迎关注公众号、留言、评论,一起学习。

    __________________________________________________________________________________

    若有帮助到您,欢迎点击推荐,您的支持是对我坚持最好的肯定(*^_^*)

  • 相关阅读:
    bzoj1318[spoj 744] Longest Permutation
    bzoj2146 Construct
    bzoj2448 挖油
    bzoj3961[WF2011]Chips Challenge
    bzoj4152[AMPPZ2014] The Captain
    AtCoder Regular Contest 076E Coneected?
    Codeforces 748D Santa Claus and a Palindrome
    bzoj3572[HNOI2014]世界树
    SQL SERVER 字段统一补0方法
    SSRS运行report builder报错 的解决方案
  • 原文地址:https://www.cnblogs.com/lovebing/p/14048266.html
Copyright © 2011-2022 走看看