Skip to content

Instantly share code, notes, and snippets.

@JAndritsch
Created October 17, 2012 19:50
Show Gist options
  • Save JAndritsch/3907715 to your computer and use it in GitHub Desktop.
Save JAndritsch/3907715 to your computer and use it in GitHub Desktop.
nginx configuration
upstream app_server {
server unix:/tmp/file_acceptor.sock fail_timeout=0;
}
server {
listen <%= port %>;
server_name localhost;
client_max_body_size 4G;
client_body_buffer_size 128k;
#access_log logs/host.access.log main;
root /vagrant/public;
try_files $uri/index.html $uri @fast_upload_endpoint;
# location ~ ^/download/(.*)$ {
# alias /home/website/files/$1;
# }
location = /upload {
proxy_pass http://127.0.0.1;
upload_pass @fast_upload_endpoint;
upload_store /home/vagrant/public/uploads 1;
upload_resumable on;
upload_state_store /home/vagrant/public/upload_state;
# set permissions on the uploaded files
upload_store_access user:rw group:rw all:r;
# Set specified fields in request body
# this puts the original filename, new path+filename and content type in the requests params
upload_set_form_field $upload_field_name.name "$upload_file_name";
upload_set_form_field $upload_field_name.content_type "$upload_content_type";
upload_set_form_field $upload_field_name.path "$upload_tmp_path";
upload_pass_form_field "^X-Progress-ID$|^authenticity_token$";
upload_cleanup 400 404 499 500-505;
track_uploads proxied 30s;
}
location @fast_upload_endpoint {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://app_server;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment