[Seaside] Using nginx file upload module
Nick Ager
nick.ager at gmail.com
Wed Jun 15 11:14:07 UTC 2011
Hi Johan,
Sorry for the delay. I have the Nginx file upload module working. In case
it's still useful here's the relevant portions of my nginx configuration:
upstream seaside {
server 127.0.0.1:9001;
server 127.0.0.1:9002;
server 127.0.0.1:9003;
fair;
}
server {
listen 80 default;
server_name www.getitmade.com;
# server_name _;
root /var/www;
location / {
try_files $uri @seaside;
}
# ensure that files are searched for locally and not passed to the
# Gems if the file isn't found on the disk
location ~* \.(gif|jpg|jpeg|png|css|html|htm|js|zip)$ {
}
location ~ fileupload {
# Pass altered request body to this location
upload_pass @seaside;
# if there's no upload file in this request, nginx generates a
405 - we use this
# to pass the request onto the 'normal' seaside processing
# The way this is achieved in the other location directives is
through a "try_files" method
# however using "try_files" results in the other directives never
being processed
error_page 405 415 = @seaside;
# Store files to this directory
# The directory is hashed, subdirectories 0 1 2 3 4 5 6 7 8 9
should exist
upload_store /var/nginx/temp 1;
# Set the file attributes for uploaded files
upload_store_access user:rw group:rw all:rw;
# Set specified fields in request body
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";
# Inform backend about hash and size of a file
# upload_aggregate_form_field "$upload_field_name.md5"
"$upload_file_md5";
upload_aggregate_form_field "$upload_field_name.size"
"$upload_file_size";
# seaside automatically assigns sequential integers to fields
with callbacks
# we want to pass those fields to the backend
upload_pass_form_field "^\d+$";
# we don't want files hanging around if the server failed to
process them.
upload_cleanup 500-505;
# file upload progress tracking - 30s is the timeout (progress
tracking is
# available 30s after the upload has finished)
# this must be the last directive in the location block.
track_uploads proxied 30s;
}
# used to report upload progress - defined by the Nginx Upload
Progress Module
# see http://wiki.nginx.org/HttpUploadProgressModule
location /progress {
report_uploads proxied;
}
location @seaside {
include /etc/nginx/fastcgi_params;
fastcgi_intercept_errors on;
fastcgi_pass seaside;
}
location /nginx_status {
# copied from
http://blog.kovyrin.net/2006/04/29/monitoring-nginx-with-rrdtool/
stub_status on;
access_log off;
allow 127.0.0.1;
deny all;
}
error_page 404 /errors/404.html;
error_page 403 /errors/403.html;
error_page 500 502 503 504 /errors/50x.html;
}
On 12 June 2011 10:28, Johan Brichau <johan at inceptive.be> wrote:
> Hi all,
>
> I'm calling for people who have got the nginx file upload module to work in
> their seaside apps...
>
> We are trying to use the Nginx file upload module but are stuck when the
> request needs to get passed on to seaside.
> We are using a configuration with a separate '/upload' location that gets
> handled by the file upload module. The request then needs to get passed to
> the upstream backend (seaside) but that request still has the URI '/upload'
> and we do not seem to get it rewritten to the '/seasideapp' URI.
>
>
> Is there anyone who has this working completely and could give us some
> advice on how solve this?
>
> The relevant parts of our nginx conf look like this:
> We also tried with a named location, but according to the docs, that makes
> the request arguments be dropped (and we need the _s & _k args for
> seaside...)
>
> Johan
>
> ----
>
> location / {
> include fastcgi_params;
> fastcgi_pass seaside;
> }
>
> # Upload form should be submitted to this location
> location /upload {
>
> # Pass altered request body to this location
> upload_pass /backend;
> upload_pass_args on;
>
>
> #Pass all fields of the form
> upload_pass_form_field ".*";
>
> # Store files to this directory
> upload_store /var/www/documents/;
>
> # Set specified fields in request body
> 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_cleanup 400 404 499 500-505;
> }
>
> location /backend
> {
> rewrite ^/upload/(.*) /seasideapp/$1 last;
> }_______________________________________________
> seaside mailing list
> seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/seaside/attachments/20110615/a5765e29/attachment-0001.htm
More information about the seaside
mailing list