nginx设置超时时间

该博客介绍了如何针对nginx配置超时时间,以应对可能超过默认60秒的请求。通过设置`proxy_send_timeout`和`proxy_read_timeout`分别为180秒,可以延长超时限制,确保复杂或多次硬件操作的请求能够完成。配置示例包括了对服务器监听端口、错误日志、访问日志、代理超时时间、请求大小限制以及不同location的处理规则。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

nginx设置超时时间

前言:

	nginx默认请求时间是60s,在特殊的情况下个别的请求时间会超过60秒,比如在进行复杂的硬件操作或重复多
次的硬件操作的时候,就会超过60s,超时会报错。
	通过配置nginx配置文件可以修改默认的超时时间:

nginx配置:(以下配置文件经过脱敏,拿自己想要的即可)

server {
        listen       *:65531;
        server_name  0.0.0.0;

        error_log   stderr warn;
        access_log  stdout main;
        proxy_send_timeout 180s;     # 设置发送超时时间,
        proxy_read_timeout 180s;	 # 设置读取超时时间。

        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;
        }
    }





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值