Upload module error

hi ,

i am using nginx upload module to upload files.i am using the following
configuration and file is uploaded successfully but 405 Not Allowed
error is returned to browser from Server.can someone help what is the
problem is?

worker_processes 20;

error_log logs/error.log notice;

working_directory /usr/local/nginx;

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 @test;

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$”;
}

Pass altered request body to a backend

location @test {
proxy_pass http://localhost:8080;
}
}
server{
listen 8080;
}
}

reason for this error 405 ?and why it is occuring based on this
configuration?

thanks in advance

Posted at Nginx Forum:

Perhaps you don’t have method=“POST” set in your upload form?

----- vetri [email protected] wrote:

default_type application/octet-stream;

Store files to this directory

$upload_content_type;

reason for this error 405 ?and why it is occuring based on this


nginx mailing list
[email protected]
nginx Info Page

Regards,
Valery K.

mr valery,

  <html>
Test upload

Select files to upload







i am using the form which is written above. i am using post in method. i
am getting the form first from server via index then i am uploading
files via that form using post.why server is returning 405?

Posted at Nginx Forum:

No one can tell you why are you getting this error with this little
information.

Pointing us at the fact that you did everything correct will not help us
solve your problem.

Please provide us at least at following:

  1. Version of nginx you are using;
  2. Exact configuration you are using;
  3. A debug log of request that is failing.

----- vetri [email protected] wrote:


i am using the form which is written above. i am using post in method. i
am getting the form first from server via index then i am uploading
files via that form using post.why server is returning 405?


Regards,
Valery K.

----- vetri [email protected] wrote:

127.0.1.1 - - [29/Mar/2011:16:21:44 +0530] "POST /upload HTTP/1.0"

301 185 “https://zd-ubuntu1:8001/” “Mozilla/5.0 (Windows; U; Windows NT
5.1; en-US; rv:1.9.2.16) Gecko/20110319 Firefox/3.6.16”
192.168.110.198 - - [29/Mar/2011:16:21:44 +0530] “POST /upload HTTP/1.1”
301 185 “https://zd-ubuntu1:8001/” “Mozilla/5.0 (Windows; U; Windows NT
5.1; en-US; rv:1.9.2.16) Gecko/20110319 Firefox/3.6.16”
192.168.110.198 - - [29/Mar/2011:16:21:44 +0530] “GET /upload/ HTTP/1.1”
405 173 “https://zd-ubuntu1:8001/” “Mozilla/5.0 (Windows; U; Windows NT
5.1; en-US; rv:1.9.2.16) Gecko/20110319 Firefox/3.6.16”

Although it’s not an access log, here is the clue: you are making a GET
request to the upload location. Upload module returns 405 in this case.

Here is what you can do about that:

  1. Do not redirect to location /upload/;
  2. Replace
  • location /upload {
  • location = /upload {

in your configuration.

this is the access log information after i uploaded single file


Regards,
Valery K.

mr valery,

1. version of the nginx i am using is  0.8.54

2.my exact config file is

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 {

    server_name  zd-ubuntu1;

    listen 8001;



    client_max_body_size 0;



    root /usr/local/nginx/html;



    location / {

     index     23.html;

this is the html form i am using to upload after getting from the

server
}

    # Upload form should be submitted to this location

    location /upload {

        # Pass altered request body to this location

        upload_pass /test;



        # Store files to this directory

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

9 should exist

        upload_store  /home/administrator/Desktop/vetri/upload/tmp;



        # Allow uploaded files to be read only by user

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

         upload_pass_form_field "^submit$|^description$";







         upload_cleanup 400-505;





         }



    # Pass altered request body to a backend

    location /test {

        proxy_pass https://zd-ubuntu1:8022;





    }

}


 server{

    listen 8022;



        }

}

3.my log information ----->this is from my access log

127.0.1.1 - - [29/Mar/2011:16:21:44 +0530] "POST /upload HTTP/1.0"

301 185 “https://zd-ubuntu1:8001/” “Mozilla/5.0 (Windows; U; Windows NT
5.1; en-US; rv:1.9.2.16) Gecko/20110319 Firefox/3.6.16”
192.168.110.198 - - [29/Mar/2011:16:21:44 +0530] “POST /upload HTTP/1.1”
301 185 “https://zd-ubuntu1:8001/” “Mozilla/5.0 (Windows; U; Windows NT
5.1; en-US; rv:1.9.2.16) Gecko/20110319 Firefox/3.6.16”
192.168.110.198 - - [29/Mar/2011:16:21:44 +0530] “GET /upload/ HTTP/1.1”
405 173 “https://zd-ubuntu1:8001/” “Mozilla/5.0 (Windows; U; Windows NT
5.1; en-US; rv:1.9.2.16) Gecko/20110319 Firefox/3.6.16”

this is the access log information after i uploaded single file

i am ready to give whatever the information needed for this problem.

and thanks for the reply

Posted at Nginx Forum:

mr valery,

        proxy_redirect off helps to turn off 405 but now it is

showing 403 forbidden.

thanks for the reply

Posted at Nginx Forum:

----- vetri [email protected] wrote:

mr valery,

        proxy_redirect off helps to turn off 405 but now it is

showing 403 forbidden.

Perhaps you can fix that by separating locations /upload and /upload/?


Regards,
Valery K.

I encounter the same problem yesterday.

Here is my fix in nginx.conf

31 if ($request_method = POST) {
32 upload_pass @test;
33 break;
34 }

The default nginx serer, only accept GET request. We need to push it to
accept POST.

Yanxin

Mr yanxin z,

     it is showing that if is a unknown directive.do we have to add

any module for if directive?

    thanks for the reply

Posted at Nginx Forum:

mr yanxinz ,

if directive is working fine but still it is showing 403 forbidden

Posted at Nginx Forum: