配置如下,经过了nginx代理,有一个下载请求,当数据量比较大的时候,超过1分钟就报错,如何调大这个1分钟的限制?

前端的请求地址
http://demo.com/wmsrest/rawMaterialIntoWarehousePC/dnOrder/li...
报错页面如下
nginx配置文件如下

# For more information on configuration, see:

# * Official English Documentation: http://nginx.org/en/docs/

# * Official Russian Documentation: http://nginx.org/ru/docs/

user nginx;

worker_processes auto;

error_log /var/log/nginx/error.log;

pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.

include /usr/share/nginx/modules/*.conf;

events {

worker_connections 1024;

}

http {

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;

tcp_nodelay on;

keepalive_timeout 65;

types_hash_max_size 4096;

include /etc/nginx/mime.types;

default_type application/octet-stream;

# Load modular configuration files from the /etc/nginx/conf.d directory.

# See http://nginx.org/en/docs/ngx_core_module.html#include

# for more information.

include /etc/nginx/conf.d/*.conf;

server {

listen 80;

listen [::]:80;

server_name _;

root /usr/share/nginx/html;

# Load configuration files for the default server block.

include /etc/nginx/default.d/*.conf;

error_page 404 /404.html;

location = /404.html {

}

error_page 500 502 503 504 /50x.html;

location = /50x.html {

}

}

server {

listen 30888;

listen [::]:30888;

server_name _;

root /usr/share/nginx/html;

location / {

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_pass http://10.163.84.83;

}

location /im {

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_pass http://10.163.84.83/im;

}

# Load configuration files for the default server block.

error_page 404 /404.html;

location = /404.html {

}

error_page 500 502 503 504 /50x.html;

location = /50x.html {

}

}

# Settings for a TLS enabled server.

#

# server {

# listen 443 ssl http2;

# listen [::]:443 ssl http2;

# server_name _;

# root /usr/share/nginx/html;

#

# ssl_certificate "/etc/pki/nginx/server.crt";

# ssl_certificate_key "/etc/pki/nginx/private/server.key";

# ssl_session_cache shared:SSL:1m;

# ssl_session_timeout 10m;

# ssl_ciphers PROFILE=SYSTEM;

# ssl_prefer_server_ciphers on;

#

# # Load configuration files for the default server block.

# include /etc/nginx/default.d/*.conf;

#

# error_page 404 /404.html;

# location = /40x.html {

# }

#

# error_page 500 502 503 504 /50x.html;

# location = /50x.html {

# }

# }

}

conf.d配置文件如下

#设置允许客户端请求的最大的单个文件字节数

client_max_body_size 100M;

##缓存配置

#proxy_connect_timeout 5;

#proxy_read_timeout 60;

#proxy_send_timeout 5;

proxy_buffer_size 16k;

proxy_buffers 4 64k;

proxy_busy_buffers_size 128k;

proxy_temp_file_write_size 128k;

#设置临时目录

proxy_temp_path /tmp;

#设置缓存目录,和上面的目录必须在一个分区里面

proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=cache_one:200m inactive=1d max_size=30g;

gzip on;

gzip_min_length 256k;

gzip_buffers 16 64k;

gzip_http_version 1.1;

gzip_comp_level 9;

gzip_types text/plain application/javascript text/css application/xml;

gzip_vary on;

upstream sgNginxAuth{

server localhost:8081;

}

upstream sgNginxMes{

server localhost:8082;

}

upstream sgAuthWeb{

server localhost:8090;

}

upstream sgMesWeb{

server localhost:16010;

}

upstream imMesWeb{

server localhost:8080;

}

upstream wmsApp{

server localhost:8061;

server localhost:8060;

}

server {

listen 80;

server_name localhost;

#charset koi8-r;

#access_log /var/log/nginx/log/host.access.log main;

rewrite "/im-mes/pln/planSchedule/deleteBarcode" "/imrest/pdm/dailyissue/deleteBarcode" break;

#rewrite "/im-mes/basicData/queryEncodeSiteCodes" "/base/auth/signToken" break;

rewrite "/im-tower/index/getOrderDataSum" "/imrest/homePage/selectNews" break;

rewrite "/im-tower/index/getBadProject" "/imrest/homePage/selectNews" break;

rewrite "/im-tower/index/getDowntime" "/imrest/homePage/selectNews" break;

rewrite "/im-mes/pln/planSchedule/issue" "/imrest/pdm/dailyissue/issue" break;

rewrite "/imrest/product/baseProductSeriesT/list" "/base/auth/signToken" break;

location / {

#proxy_connect_timeout 10;

#proxy_send_timeout 30;

#proxy_read_timeout 30;

#proxy_set_header Host 10.18.70.69:30001;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_pass http://sgNginxAuth/;

}

location /images {

root /usr/share/nginx/html;

expires 30d;

break;

}

# location ~.*\.(jpg|jepg|gif|css|png|ico|html)?$ {

# location ~.*\.(jpg|jepg|gif|css|png|ico)?$ {

# root /usr/share/nginx/html;

# expires 30d;

# break;

# }

location /im {

#proxy_connect_timeout 10;

#proxy_send_timeout 30;

#proxy_read_timeout 30;

#proxy_set_header Host 10.18.70.69:30001;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_pass http://sgNginxMes/;

#proxy_pass http://10.163.84.83/im;

#return 301 http://indiamom.haier.net:30888;

}

location /base/ {

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_pass http://localhost:8090;

}

location /imrest/ {

#proxy_redirect off;

#proxy_connect_timeout 10;

#proxy_send_timeout 30;

#proxy_read_timeout 30;

#proxy_set_header Host cosmo.cosmoim-lsb.haier.net;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_pass http://sgMesWeb;

# proxy_pass http://10.163.84.83/imrest;

}

location /im-mes/ {

#proxy_redirect off;

#proxy_connect_timeout 10;

#proxy_send_timeout 30;

#proxy_read_timeout 30;

#proxy_set_header Host cosmo.cosmoim-lsb.haier.net;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_pass http://imMesWeb;

}

location /wms {

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_pass http://localhost:8083;

}

location /wmsbase/ {

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_pass http://localhost:8181;

rewrite "^/wmsbase/(.*)$" /$1 break;

}

location /wmsrest/ {

#proxy_redirect off;

#proxy_connect_timeout 10;

#proxy_send_timeout 30;

#proxy_read_timeout 30;

#proxy_set_header Host cosmo.cosmoim-lsb.haier.net;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_pass http://localhost:8181;

}

location /wmspda/ {

#proxy_redirect off;

#proxy_connect_timeout 10;

#proxy_send_timeout 30;

#proxy_read_timeout 30;

#proxy_set_header Host cosmo.cosmoim-lsb.haier.net;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_pass http://wmsApp;

#rewrite "^/wmspda/(.*)$" /$1 break;

}

location /mes/ {

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_pass http://10.163.84.83:80;

rewrite "^/im/(.*)$" /$1 break;

}

# location @fallback{

# rewrite .* /index.html break;

# }

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html

#

error_page 500 502 503 504 /50x.html;

location = /50x.html {

root /usr/share/nginx/html;

}

}

server {

listen 30887;

server_name localhost;

location / {

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_pass http://localhost:8099;

}

location /wmspda {

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_pass http://wmsApp;

}

location /wmsbase/ {

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_pass http://localhost:8181;

rewrite "^/wmsbase/(.*)$" /$1 break;

}

location /wmsrest/ {

#proxy_redirect off;

#proxy_connect_timeout 10;

#proxy_send_timeout 30;

#proxy_read_timeout 30;

#proxy_set_header Host cosmo.cosmoim-lsb.haier.net;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_pass http://localhost:8181;

}

location /base/ {

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_pass http://localhost:8090;

}

}


回答:

自己手动设置一下nginx的几个timeout;

  1. client_body_timeout: 这个参数用于指定请求体的超时时间。它决定了Nginx等待客户端发送请求体的最长时间。如果超过这个时间,Nginx将关闭连接。默认值是60秒。
  2. client_header_timeout: 这个参数用于指定请求头的超时时间。它决定了Nginx等待客户端发送请求头的最长时间。如果超过这个时间,Nginx将关闭连接。默认值是60秒。
  3. send_timeout: 这个参数用于指定Nginx发送响应给客户端的超时时间。它决定了Nginx等待客户端接收响应的最长时间。如果超过这个时间,Nginx将关闭连接。默认值是60秒。
  4. keepalive_timeout: 这个参数用于指定持久连接的超时时间。它决定了Nginx保持TCP连接打开状态的最长时间。如果超过这个时间,Nginx将关闭连接。默认值是75秒。
  5. proxy_read_timeout: 当Nginx作为反向代理时,这个参数用于指定从上游服务器读取响应的超时时间。它决定了Nginx等待上游服务器响应的最长时间。如果超过这个时间,Nginx将关闭连接。默认值是60秒。
  6. proxy_send_timeout:用于设置向上游服务器发送请求的超时时间。单位为秒,默认值为60秒。
  7. proxy_connect_timeout: 当Nginx作为反向代理时,这个参数用于指定与上游服务器建立连接的超时时间。它决定了Nginx等待上游服务器建立连接的最长时间。如果超过这个时间,Nginx将关闭连接。默认值是5秒。

proxy_send_timeoutproxy_read_timeout还有client_body_timeout都设置长一点

以上是 配置如下,经过了nginx代理,有一个下载请求,当数据量比较大的时候,超过1分钟就报错,如何调大这个1分钟的限制? 的全部内容, 来源链接: utcz.com/p/945386.html

回到顶部