700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > 上传大文件超时upstream timed out nginx配置修改

上传大文件超时upstream timed out nginx配置修改

时间:2024-07-16 08:51:10

相关推荐

上传大文件超时upstream timed out  nginx配置修改

修改配置文件

location ~ ^/(admin|excel|app-download|file)/(.*)$ {proxy_next_upstream http_404 http_500 http_502 http_503 http_504 error timeout invalid_header;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $remote_addr;proxy_set_header Host $host;proxy_read_timeout 60s;proxy_connect_timeout 60s;proxy_send_timeout 60s;proxy_pass http://dm_server/dmback/$1/$2?$args;}

其中 location 用了正则表达式(参考教程:/p/9fd2ea5b7d12 /regexp/regexp-metachar.html)

~ ^/(admin|excel|app-download|file)/(.*)$

波浪号(~):表示执行正则匹配,但区分大小写

小括号():(pattern),匹配 pattern 并获取这一匹配

竖线(|):x|y,匹配 x 或 y

整体表示: 搜索location里包含admin|excel|app-download|file 的地址,区分大小写其中3个关键参数

proxy_connect_timeout 60s;nginx 与 upstream server 的连接超时时间,默认为 60s;根据应用不同可配置

Syntax:proxy_connect_timeout time;Default:proxy_connect_timeout 60s;Context:http, server, locationDefines a timeout for establishing a connection with a proxied server. It should be noted that this timeout cannot usually exceed 75 seconds.

proxy_read_timeout 60s;nginx 接收 upstream server 数据超时, 默认 60s, 如果连续的 60s 内没有收到 1 个字节, 连接关闭;

Syntax:proxy_read_timeout time;Default:proxy_read_timeout 60s;Context:http, server, locationDefines a timeout for reading a response from the proxied server. The timeout is set only between two successive read operations, not for the transmission of the whole response. If the proxied server does not transmit anything within this time, the connection is closed.

proxy_send_timeout 60s;nginx 发送数据至 upstream server 超时, 默认 60s, 如果连续的 60s 内没有发送 1 个字节, 连接关闭;

Syntax:proxy_send_timeout time;Default:proxy_send_timeout 60s;Context:http, server, locationSets a timeout for transmitting a request to the proxied server. The timeout is set only between two successive write operations, not for the transmission of the whole request. If the proxied server does not receive anything within this time, the connection is closed.

官方文档:/en/docs/http/ngx_http_proxy_module.html

其中关键是proxy_read_timeout,proxy_connect_timeout

因为之前是proxy_read_timeout 设置为30s,proxy_connect_timeout为10秒

改大就行,最终我改为300s

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。