欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

nginx設(shè)置超時時間的問題及解決方案

 更新時間:2024年02月07日 11:13:10   作者:you秀  
程序在處理大量數(shù)據(jù),接口超過1分鐘(默認的)未返回數(shù)據(jù),導致等待超時,出現(xiàn)這種情況,我們可以先優(yōu)化程序,縮短執(zhí)行時間,可以調(diào)大nginx超時限制的參數(shù),使程序可以正常執(zhí)行,本文介紹nginx設(shè)置超時時間及504 Gateway Time-out的問題解決方案,一起看看吧

nginx設(shè)置超時時間

前言:

    nginx默認請求時間是60s,在特殊的情況下個別的請求時間會超過60秒,比如在進行復雜的硬件操作或重復多
次的硬件操作的時候,就會超過60s,超時會報錯。
    通過配置nginx配置文件可以修改默認的超時時間:

nginx配置:(以下配置文件經(jīng)過脫敏,拿自己想要的即可)

server {
        listen       *:65531;
        server_name  0.0.0.0;
        error_log   stderr warn;
        access_log  stdout main;
        proxy_send_timeout 180s;     # 設(shè)置發(fā)送超時時間,
        proxy_read_timeout 180s;	 # 設(shè)置讀取超時時間。
        location ^~/apig/ {
          client_max_body_size                    "100m";
          proxy_pass https://localhost:8086/;
        }
        location / {
            root   /opt/ty/console;
            index  index.html index.htm;
        }
        location = /index.html {
            root   /opt/ty/console;
            index  index.html index.htm;
            add_header Cache-Control "no-cache, no-store";
        }
        error_page  404              /;
        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }

nginx出現(xiàn)504 Gateway Time-out

問題

nginx訪問出現(xiàn)504 Gateway Time-out

常見原因:程序在處理大量數(shù)據(jù),接口超過1分鐘(默認的)未返回數(shù)據(jù),導致等待超時。

出現(xiàn)這種情況,我們可以先優(yōu)化程序,縮短執(zhí)行時間??梢哉{(diào)大nginx超時限制的參數(shù),使程序可以正常執(zhí)行。

解決方法

nginx配置nginx.conf中,設(shè)置以下幾個參數(shù),增加超時時間配置:

如果使用了Nginx的代理,可以在下面這里加上下面三個配置:

location /foo {
     proxy_pass http://xxx.xxx.xxx.xxx:8080/foo;
     proxy_connect_timeout      300s;       # 默認60s
     proxy_send_timeout           300s;       # 默認60s
     proxy_read_timeout           300s;       # 默認60s
}

到此這篇關(guān)于nginx設(shè)置超時時間的文章就介紹到這了,更多相關(guān)nginx設(shè)置超時時間內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評論