使用nginx/puma下载的Rails 5.2.1 ActiveStorage文件被截断

使用nginx/puma下载的Rails 5.2.1 ActiveStorage文件被截断,nginx,ruby-on-rails-5,rails-activestorage,Nginx,Ruby On Rails 5,Rails Activestorage,我的第一个ActiveStorage项目在开发(仅限puma)上运行良好,但在生产(nginx/puma)上,我遇到了下载显示为截断文件的大文件的问题 例如,一个大小为24.1MB的上传文件的下载量为5MB(截断) 我主要上传pdf文件,上传的文件是完整的(在服务器上检查)&预览效果很好 所有环境都使用config.active\u storage.service=:local config/storage.yml Rails配置/puma.rb 使用proxy\uhttp\uversion1.

我的第一个ActiveStorage项目在开发(仅限puma)上运行良好,但在生产(nginx/puma)上,我遇到了下载显示为截断文件的大文件的问题

例如,一个大小为24.1MB的上传文件的下载量为5MB(截断)

我主要上传pdf文件,上传的文件是完整的(在服务器上检查)&预览效果很好

所有环境都使用
config.active\u storage.service=:local

config/storage.yml Rails配置/puma.rb
使用
proxy\uhttp\uversion1.1

默认情况下,nginx使用http1.0进行代理,代理不支持分块传输编码


谢谢@amiuhle,这解决了我的问题。
local:
  service: Disk
  root: <%= Rails.root.join("storage") %>
upstream app {
    # Path to Puma SOCK file, as defined previously
    server unix:/home/deploy/rails/shared/sockets/puma.sock fail_timeout=0;
}

server {
        listen 80;

        root /home/deploy/rails/public;

        try_files $uri/index.html $uri @app;

        # Make site accessible from http://localhost/
        server_name localhost;

        location @app {
            proxy_pass http://app;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Host $http_host;
            proxy_redirect off;
        }

        error_page 500 502 503 504 /500.html;
        keepalive_timeout 10;
        client_max_body_size 4G;
}
# Default to production
rails_env = ENV['RAILS_ENV'] || "production"
environment rails_env
# Change to match your CPU core count
if rails_env == 'production'
  workers 2
else
  workers 1
end

# Min and Max threads per worker
threads 1, 6

app_dir = File.expand_path("../..", __FILE__)
shared_dir = "#{app_dir}/shared"

if rails_env == 'production'
  # Set up socket location
  bind "unix://#{shared_dir}/sockets/puma.sock"

  # Logging
  stdout_redirect "#{shared_dir}/log/puma.stdout.log", "#{shared_dir}/log/puma.stderr.log", true

  # Set master PID and state locations
  pidfile "#{shared_dir}/pids/puma.pid"
  state_path "#{shared_dir}/pids/puma.state"
  activate_control_app

  on_worker_boot do
    require "active_record"
    ActiveRecord::Base.connection.disconnect! rescue ActiveRecord::ConnectionNotEstablished
    ActiveRecord::Base.establish_connection(YAML.load_file("#{app_dir}/config/database.yml")[rails_env])
  end
end