Nginx upload module (v 2.2.0) :: 502 Bad Gateway

HI,

I have compiled newest version of nginx (nginx/1.1.1) with nginx upload
module (v 2.2.0), also the example config (nginx.conf) was copied from
GitHub - vkholodkov/nginx-upload-module: A module for nginx web server for handling file uploads using multipart/form-data encoding (RFC 1867). into nginx direcoty.
The html form is also copied from this location. So the installation and
configuration is oryginal now without any changes.

I’m getting some errors while uploading the file;

The html form: ‘502 Bad Gateway’;

The nginx error.log (/usr/local/nginx/logs/error.log):


2011/09/05 08:35:15 [error] 21161#0: *6 connect() failed (111:
Connection refused) while connecting to upstream, client: 192.168.0.165,
server: , request: “POST /upload HTTP/1.1”, upstream:
http://127.0.0.1:8080/upload”, host: “192.168.0.127”, referrer:
http://192.168.0.127/http/upload.html

Maybe it’s a problem of my wrong understanding how does it works, I do
not understand why in this example config the proxy_pass is going
through local 8080 port but the server in this configuration is not
listening on such port.

Please help.


best regards
Piotr P.

On Mon, 05 Sep 2011 08:59:58 +0200, Piotr P. [email protected] wrote:

I’m getting some errors while uploading the file;
The html form: ‘502 Bad Gateway’;
The nginx error.log (/usr/local/nginx/logs/error.log):

2011/09/05 08:35:15 [error] 21161#0: *6 connect() failed (111:
Connection refused) while connecting to upstream, client:
192.168.0.165, server: , request: “POST /upload HTTP/1.1”, upstream:
http://127.0.0.1:8080/upload”, host: “192.168.0.127”, referrer:
http://192.168.0.127/http/upload.html

Your setup includes:
client_max_body_size 100m;

Do you also your php.ini configured to accommodate 100m files?
Check:
memory_limit (should be something able to cope with 100M files)
post_max_size (should be >= 110M)
file_uploads (should be On)
upload_max_filesize (should be >= 100M)

Regards,
M.

Your setup includes:
client_max_body_size 100m;

Do you also your php.ini configured to accommodate 100m files?
Check:
memory_limit (should be something able to cope with 100M files)
post_max_size (should be >= 110M)
file_uploads (should be On)
upload_max_filesize (should be >= 100M)

Thank you all for help!

I found the solution on this thread:
http://www.ruby-forum.com/topic/1432037

The problem was that I did not wrote the form handler script.

This is my working configuration of nginx:

/usr/local/nginx/conf/nginx.conf:

worker_processes 20;

error_log logs/error.log notice;

working_directory /usr/local/nginx/html;

events {
worker_connections 1024;
}

http {
include mime.types;
default_type application/octet-stream;

 server {
     listen       80;
     client_max_body_size 100m;

     # Upload form should be submitted to this location
     location /upload {
         # Pass altered request body to this location
         upload_pass   /my-form-handler;

         # Store files to this directory
         # The directory is hashed, subdirectories 0 1 2 3 4 5 6 7 8

9 should exist
upload_store /tmp 1;

         # Allow uploaded files to be read only by user
         upload_store_access user:r;

         # 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;

         upload_pass_form_field "^submit$|^description$";
     }

    include fastcgi.conf;
    location = /my-form-handler {
       fastcgi_pass  127.0.0.1:9000;
     }

 }

}

/usr/local/nginx/html/my-form-handler

<?php header("Content-Type: text/plain"); print("GET: "); print_r($_GET); print("POST: "); print_r($_POST); print("FILES: "); print_r($_FILES); ?>


best regards
Piotr P.