nginx代理服务器无法上载大于1 MB的文件
下面是我正在使用的nginx配置(nginx是一个docker容器)-nginx用作所有后端api服务器的代理服务器。当我试图上传文件时,如果文件大小大于1MB,就会出现错误。已尝试给出所有可能的解决方案,但无法解决。任何帮助都是有用的nginx代理服务器无法上载大于1 MB的文件,nginx,Nginx,下面是我正在使用的nginx配置(nginx是一个docker容器)-nginx用作所有后端api服务器的代理服务器。当我试图上传文件时,如果文件大小大于1MB,就会出现错误。已尝试给出所有可能的解决方案,但无法解决。任何帮助都是有用的 server { listen 80; server_name abcd.dev; #rewrite ^/(.*)/$ /$1 permanent; charset utf-8; keepalive_timeout 300
server {
listen 80;
server_name abcd.dev;
#rewrite ^/(.*)/$ /$1 permanent;
charset utf-8;
keepalive_timeout 300s;
gzip on;
gzip_http_version 1.1;
gzip_vary on;
gzip_comp_level 6;
gzip_proxied any;
gzip_buffers 16 8k;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
client_body_in_file_only clean;
client_body_buffer_size 10M;
client_max_body_size 10M;
sendfile on;
send_timeout 300s;
proxy_buffering off;
proxy_request_buffering off;
proxy_buffer_size 10M;
proxy_buffers 32 4m;
proxy_busy_buffers_size 10m;
proxy_max_temp_file_size 1024m;
proxy_temp_file_write_size 10m;
proxy_connect_timeout 300s;
proxy_read_timeout 300s;
proxy_send_timeout 300s;
proxy_set_header HOST $host;
#X-Forwarded-Proto header gives the proxied server information about the schema of the original client request (whether it was an http or an https request).
proxy_set_header X-Forwarded-Proto $scheme;
#The X-Real-IP is set to the IP address of the client so that the proxy can correctly make decisions or log based on this information.
proxy_set_header X-Real-IP $remote_addr;
#The X-Forwarded-For header is a list containing the IP addresses of every server the client has been proxied through up to this point.
#In the example above, we set this to the $proxy_add_x_forwarded_for variable.
#This variable takes the value of the original X-Forwarded-For header retrieved from the client and adds the Nginx server's IP address to the end.
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
error_page 404 /custom_404.html;
location = /custom_404.html {
root /usr/share/nginx/html;
internal;
}
error_page 500 502 503 504 /custom_50x.html;
location = /custom_50x.html {
root /usr/share/nginx/html;
internal;
}
location / {
location ~ ^/(uploads/|vendor/|images/|img/|javascript/|js/|css/|stylesheets/|flash/|media/|static/|robots.txt|humans.txt|favicon.ico) {
proxy_pass http://ui-service;
}
if ($domain) {
set $args $args&nethumUrl=$domain;
proxy_pass http://ui-service$uri$is_args$args;
}
proxy_pass http://ui-service$uri$is_args$args;
}
...........
}
我可以上传任何小于1MB的文件,但更大的文件无法上传。低于错误-
error 2017/03/02 06:52:37 [error] 38#38: *89 recv() failed (104: Connection reset by peer) while reading response header from upstream
您在
upload\u max\u filesize
上的php.ini设置是什么?同时尝试添加客户机\u最大\u身体\u尺寸10M。错误消息表示连接已被后端(Java服务器)关闭。查看it日志以找出问题的根源。我遇到了某种类型的问题。通过对下一个(在nginx后面)web服务器进行微调,解决了这个问题。但是,http
部分中的一些设置可能会有所帮助
default_type application/octet-stream;
sendfile on;
keepalive_timeout 300;
client_max_body_size 100m;
gzip on;
我没有使用php。它是一个向Java服务器发送请求的代理服务器,我在那个里也有10M的限制。如果我直接上传到我的Java服务器,它可以正常工作。您可以在位置块内设置configclient\u max\u body\u size
param并重试吗?错误消息显示连接已由后端重置。可以显示java后端的日志吗?请注意,代理nginx时默认使用http/1.0。您在下面说过,直接上传到java应用程序效果很好——让我们尝试在测试客户端中显式使用http/1.0,或者使用proxy_http_1.1版来确保测试是公平的。是的,任何来自java应用程序的日志都会很有帮助,否则我们只能猜测发生了什么事情路径是nginx->node proxy->javaapp@Ananda你能显示节点代理和java应用的日志吗?问题的根源似乎是其中之一。也可以通过将客户端\u max\u body\u size
设置为0
(请参阅)来禁用对客户端正文大小的检查