当前位置: 首页 > 知识库问答 >
问题:

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

段干英杰
2023-10-24

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

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

共有1个答案

岳朝
2023-10-24

自己手动设置一下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都设置长一点

 类似资料:
  • 首先也是最重要的: null 现在,这项工作一直很好,直到上周,我们有一个激增(10倍以上)的流量。从那时候起,Flink变成了香蕉。检查点大小开始从500MB缓慢增长到20GB,检查点时间大约需要1分钟,并且随着时间的推移而增长。应用程序开始失败,并且永远无法完全恢复,事件迭代器的年龄增长也永远不会下降,因此没有新的事件被消耗。 因为我是一个新的闪现,我不确定我做滑动计数的方式是不是完全没有优化

  • 我有一个Web应用程序,它的web.xml超时为1分钟,但它从未超时过这个值。它对其他值(如5,9,10或25分钟)超时,但从未超时1分钟。这是Tomcat 8的最小会话超时限制吗?

  • 下面是我的配置: 但是,我在1分30秒后得到504网关超时错误。但不是根据我上面的配置,原因是什么?我怎么才能让它工作更多秒。

  • 我得到这个错误后,我的第一个请求: 超过了mybusinessaccountmanagement服务的配额指标“请求”和限制“每分钟请求数”的配额。古格里皮斯。com' 在我第一次提出要求后,我怎么能超过我的配额?

  • 如何通过按下按钮创建2分钟的计时器?我想创建一个按钮,按下此按钮后将无法点击2分钟

  • 我需要向一个外部api发送数据,但是这个API对每个endpoint的请求有一个限制(即:每分钟60个请求)。 数据来自 Kafka,然后每条消息都会转到 redis(因为我可以发送包含 200 个项目的请求)。因此,我使用简单的缓存来帮助我,我可以保证如果我的服务器出现故障,我不会丢失任何消息。 问题是,有些时候,Kafka开始向许多消息发送消息,然后redis开始增长(超过100万条消息发送到