Skip to content

Instantly share code, notes, and snippets.

@vakiliy
Last active August 29, 2015 13:56
Show Gist options
  • Save vakiliy/9233767 to your computer and use it in GitHub Desktop.
Save vakiliy/9233767 to your computer and use it in GitHub Desktop.
Send big file
passenger_set_cgi_param HTTP_X_ACCEL_MAPPING /local/storage/=/storage/;
location /storage/ {
internal;
alias /local/storage/;
}
# From 'lib/rack/sendfile'
location ~ /storage/(.*) {
internal;
alias /local/storage/$1;
}
location / {
proxy_redirect off;
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 X-Sendfile-Type X-Accel-Redirect;
proxy_set_header X-Accel-Mapping /local/storage/=/storage/;
proxy_pass http://127.0.0.1:8080/;
}
config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'
# ... auth before
def uploads
send_file "/local/storage/#{file_name}", :disposition => 'inline'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment