小编ips*_*tic的帖子

NGINX下载速度慢,以send_file开头

我有一个下载链接转到控制器中的方法,该控制器使用send_file,以便我可以重命名该文件(它是一个带有uuid作为文件名的MP3).点击链接后,我在NGINX日志和Rails日志中看到了请求,但下载前需要90秒.我已尝试使用proxy_buffers和client _*_ buffers进行各种设置,但没有任何影响.我有一个HTML5音频播放器,它使用文件的真实URL,它立即流媒体文件,没有延迟.

我的NGINX配置:

upstream app {
  server unix:/home/archives/app/tmp/unicorn.sock fail_timeout=0;
}

server {
  listen      80 default deferred;
  server_name archives.example.com;
  root        /home/archives/app/public/;

  client_max_body_size 200M;
  client_body_buffer_size 100M;
  proxy_buffers 2 100M;
  proxy_buffer_size 100M;
  proxy_busy_buffers_size 100M;

  try_files /maintenance.html $uri/index.html $uri.html $uri @production;

  location @production {
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_set_header X-Sendfile-Type X-Accel-Redirect;
    proxy_set_header X-Accel-Mapping /home/archives/app/public/uploads/audio/=/uploads/audio/;
    proxy_redirect off;
    proxy_pass http://app;
  }

  location ~ "^/assets/*" {
    gzip_static on;
    expires     max;
    add_header  Cache-Control public;
  }

  location ~ (?:/\..*|~)$ {
    access_log off;
    log_not_found off;
    deny all; …
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails nginx

10
推荐指数
1
解决办法
714
查看次数

标签 统计

nginx ×1

ruby-on-rails ×1