등록 된 사용자에게 큰 정적 파일을 제공하는 레일 앱이 있습니다. 훌륭한 지침서 인 여기에 따라 구현할 수있었습니다 : Protected downloads with nginx, Rails 3.0, and #send_file. 다운로드 및 그 밖의 모든 기능은 훌륭하게 작동하지만이 문제가 있습니다. Content-Length
헤더가 전송되지 않습니다.Nginx 뒷받침 레일즈 앱에서 내용 길이 헤더가 누락되었습니다
그것은 작은 파일에 대한 괜찮아,하지만 다운로드 관리자와 브라우저가 진전을 보여주지 않기 때문에이 큰 파일을 다운로드 할 때 정말 실망 가져옵니다. 이 문제를 어떻게 해결할 수 있습니까? nginx
구성에 무언가를 추가해야합니까, 아니면 레일 컨트롤러의 send_file
메서드에 다른 옵션을 전달해야합니까? 나는 오랫동안 온라인에서 검색을 해왔지만 성공하지 못했습니다. 도와주세요! 감사!
upstream unicorn {
server unix:/tmp/unicorn.awesomeapp.sock fail_timeout=0;
}
server {
listen 80 default_server deferred;
# server_name example.com;
root /home/deploy/apps/awesomeapp/current/public;
location ~ /downloads/(.*) {
internal;
alias /home/deploy/uploads/$1;
}
location ^~ /assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
}
try_files $uri/index.html $uri @unicorn;
location @unicorn {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_set_header X-Sendfile-Type X-Accel-Redirect;
proxy_set_header X-Accel-Mapping /downloads/=/home/deploy/uploads/;
proxy_pass http://unicorn;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 20M;
keepalive_timeout 10;
}
싶어 upvote에, 일부 웹 서버가 제대로 작동 할 수 있어야합니다. – Xiangyu