Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am trying to make nginx accept POST and PUT methods to upload files. I have compiled nginx_upload_module-2.2.0.
I can't find any how to. I simply want to use only nginx for this, no reverse proxy, no other backend and no php.
Is this achievable?

this is my conf:

nginx version: nginx/1.2.3TLS SNI support enabled configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-mail --with-mail_ssl_module --with-file-aio --with-ipv6 --with-cc-opt='-O2 -g' --add-module=/usr/src/nginx-1.2.3/nginx_upload_module-2.2.0

server {
listen       80;
server_name  example.com;

location / {
root   /html;
autoindex on;
}

location /upload {
root    /html;
autoindex on;
upload_store /html/upload 1;

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_aggregate_form_field "$upload_field_name.md5" "$upload_file_md5";
upload_aggregate_form_field "$upload_field_name.size" "$upload_file_size";
upload_pass_form_field "^submit$|^description$";
upload_cleanup 400 404 499 500-505;
}
}

And as an upload form I'm trying to use the one listed at the end of this page: http://grid.net.ru/nginx/upload.en.html

share|improve this question

2 Answers 2

The third party upload module does not support PUT at all. If you want to use PUT uploads you must do so using standard nginx upload handling.

share|improve this answer
    
forget about the methods then. I'm just interested in how to upload. –  w00t Aug 28 '12 at 8:58
    
I noticed that you gave more details on the nginx mailing list so I ended up responding there instead. –  Martin Fjordvald Aug 28 '12 at 13:45

Regarding POST requests: Maybe you didn't create the directories 0 1 2 3 4 5 6 7 8 9 in your upload target dir?

You can always use DAV for PUT requests, you got it compiled into your nginx already:

location /upload {
  alias     upload/data;
  client_body_temp_path  upload/client_tmp;

  dav_methods  PUT DELETE MKCOL COPY MOVE;

  create_full_put_path   on;
  dav_access             group:rw  all:r;

}

And you'll need this (in http or location):

client_max_body_size 10000m;

Now have a try:

curl -T ubuntu-10.04.4-alternate-amd64.iso http://localhost/upload/blah2

Cheers! Georg

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.