在上游读取时中间“上游过早closures连接”

我在服务器上收到一个中间的“上游过早closures连接,而上游读取”错误。 错误只发生在从Amazon S3向服务器请求的数据上,而不在服务器自身的任何文件上。

我的设置如下:

1基于Nginx nginx版本的负载均衡器:nginx / 1.11.5(离开Ubuntu库)

它的configuration是:

server { server_name example.com client_body_timeout 12s; client_header_timeout 12s; keepalive_timeout 15s; access_log off; proxy_connect_timeout 1000s; proxy_send_timeout 1000s; proxy_read_timeout 1000s; send_timeout 1000s; location / { set $ua $http_user_agent; if ($http_user_agent = "") { set $ua "Fixing-Empty-User-Agent"; } proxy_pass http://front_least; proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504; proxy_redirect off; proxy_buffering off; proxy_ignore_client_abort on; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Accept-Encoding ""; } } upstream front_least { least_conn; server localF1.example.com; server localF2.example.com; server f1.example.com backup; # Public ports server f2.example.com backup; # Public ports keepalive 32; } 
  1. 2个有Nginx的前台服务器。 它们之间的configuration是完全一样的,在这里我只显示部分configuration,全部configuration太大。

Fconfiguration(相关部分恕我直言):

 # Fix S3 Content Type error map $uri $custom_content_type { default "binary/octet-stream"; ~(.*\.png)$ "image/png"; ~(.*\.jpg)$ "image/jpeg"; ~(.*\.jpeg)$ "image/jpeg"; ~(.*\.gif)$ "image/gif"; ~(.*\.ico)$ "image/x-icon"; } server { listen 80; server_name example.com *.example.com; ssl_prefer_server_ciphers on; ssl_protocols SSLv3 TLSv1; gzip on; gzip_disable "MSIE [1-6]\.(?!.*SV1)"; gzip_proxied any; gzip_buffers 16 8k; gzip_types text/plain text/css application/javascript text/xml application/xml+rss; gzip_vary on; pagespeed on; ... Huje amount of lines related to pagespeed ... location /gallery/ { try_files $uri @s3icons; } location /gallery_thumbnails/ { try_files $uri @s3icons; } location /icon/ { try_files $uri @s3icons; } location /screenshot/ { try_files $uri @s3icons; } location /vendor/ { try_files $uri @s3icons; } location @s3icons { proxy_set_header Host 'bucket_name.s3.amazonaws.com'; proxy_set_header Authorization ''; proxy_hide_header x-amz-id-2; proxy_hide_header x-amz-request-id; proxy_hide_header Set-Cookie; proxy_ignore_headers "Set-Cookie"; proxy_intercept_errors on; proxy_hide_header Content-Type; add_header Content-Type $custom_content_type; proxy_http_version 1.1; proxy_set_header Connection ""; proxy_pass http://s3_icons; } include common/error.conf; include common/deny.conf; } # Define a mapping used to mark HTML as uncacheable. map $upstream_http_content_type $new_cache_control_header_val { default $upstream_http_cache_control; "~*text/html" "no-cache, max-age=0"; } upstream s3_images { server bucket_1.s3.amazonaws.com; keepalive 10; } upstream s3_icons { server bucket_2.s3.amazonaws.com; keepalive 10; } 

现在,我只得到来自S3的图像的错误,如果我从负载平衡器指向Front服务器,没有错误。 如果我检查在Curl或浏览器中的日志中的同一个文件,我得到的图像没有问题。 但日志显示有问题。