我有一个使用 Express 的 NodeJS 应用程序。此应用程序无需通过 Nginx 访问即可完美运行。此应用程序需要上传约 100Gb 的文件。如果我通过 Nginx 访问此应用程序,则会发生以下情况:
413 Request Entity Too Large
查看日志时:
2016/01/26 11:09:07 [error] 21508#0: *1 upstream timed out (110: Connection timed out) while sending request to upstream, client: 10.9.56.33, server: 161.116.xxx.xx, request: "POST /metagenomics/pipeline/ HTTP/1.1", upstream: "http://127.0.0.1:8080/metagenomics/pipeline/", host: "10.4.2.11", referrer: "http://10.4.2.11/metagenomics/"
2016/01/26 11:09:07 [error] 21508#0: *1 client intended to send too large body: 32421677970 bytes, client: 10.9.56.33, server: 161.116.xxx.xx, request: "POST /metagenomics/pipeline/ HTTP/1.1", upstream: "http://127.0.0.1:8080/metagenomics/pipeline/", host: "10.4.2.11", referrer: "http://10.4.2.11/metagenomics/"
因此,我在上传大文件时遇到超时和问题。我的 nginx 配置是:
upstream metagenomics {
server localhost:8080;
}
# HTTP server
server {
listen 80;
server_name 161.116.xxx.xx;
server_name_in_redirect off;
access_log /var/log/nginx/metagenomics-80.access.log;
error_log /var/log/nginx/metagenomics-80.error.log;
# Use utf-8
charset utf-8;
source_charset utf-8;
# output compression saves bandwidth
gzip on;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_proxied any;
gzip_types text/plain text/html text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;
# Default root
root /usr/share/nginx/html/;
# Default index
index index.html;
error_page 404 /404.html;
location = /40x.html {
root /usr/share/nginx/html/;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html/;
}
}
location /metagenomics/ {
proxy_pass http://localhost:8080/metagenomics/;
root /Synology/server_Metagenomics/server/;
index index.html;
}
location /metagenomics/pipeline/ {
proxy_pass http://localhost:8080/metagenomics/pipeline/;
##managing file issues
client_max_body_size 100G;
client_body_temp_path /Synology/server_Metagenomics/server/files/;
#proxy_read_timeout 5s;
#proxy_send_timeout 5s;
#proxy_next_upstream_timeout 5s;
}
}
这是以接受大文件请求的方式配置的。发生了什么?