# Upload module error

**URL:** <https://www.ruby-forum.com/t/upload-module-error/205091>\
**Category:** NGINX\
**Created:** [March 29, 2011, 11:01am UTC](https://www.ruby-forum.com/t/upload-module-error/205091 "2011-03-29T11:01:14Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [March 29, 2011, 11:01am UTC](https://www.ruby-forum.com/t/upload-module-error/205091/1 "2011-03-29T11:01:14Z")

</div>

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](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:

> **[upload module error](https://forum.nginx.org/read.php?2,186553,186553#msg-186553)**
>
> 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;

---

<div class="post-metadata">

**Author:** ![vetri](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/3ab097/32.png) [@vetri](https://www.ruby-forum.com/u/vetri)\
**Post date:** [March 29, 2011, 11:29am UTC](https://www.ruby-forum.com/t/upload-module-error/205091/2 "2011-03-29T11:29:01Z")

</div>

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

----- vetri [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [mailman.nginx.org archive](http://nginx.org/mailman/listinfo/nginx)

## –

Regards,  
Valery K.

---

<div class="post-metadata">

**Author:** ![vetri](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/3ab097/32.png) [@vetri](https://www.ruby-forum.com/u/vetri)\
**Post date:** [March 29, 2011, 11:50am UTC](https://www.ruby-forum.com/t/upload-module-error/205091/3 "2011-03-29T11:50:40Z")

</div>

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:

> **[Re: upload module error](https://forum.nginx.org/read.php?2,186553,186568#msg-186568)**
>
> 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;

---

<div class="post-metadata">

**Author:** ![vetri](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/3ab097/32.png) [@vetri](https://www.ruby-forum.com/u/vetri)\
**Post date:** [March 29, 2011, 12:11pm UTC](https://www.ruby-forum.com/t/upload-module-error/205091/4 "2011-03-29T12:11:41Z")

</div>

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 [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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.

---

<div class="post-metadata">

**Author:** ![vetri](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/3ab097/32.png) [@vetri](https://www.ruby-forum.com/u/vetri)\
**Post date:** [March 29, 2011, 1:47pm UTC](https://www.ruby-forum.com/t/upload-module-error/205091/5 "2011-03-29T13:47:24Z")

</div>

----- vetri [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ```
> 127.0.1.1 - - [29/Mar/2011:16:21:44 +0530] "POST /upload HTTP/1.0"
> 
> ```
> 
> 301 185 “[https://zd-ubuntu1:8001/](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/](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/](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.

---

<div class="post-metadata">

**Author:** ![vetri](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/3ab097/32.png) [@vetri](https://www.ruby-forum.com/u/vetri)\
**Post date:** [March 29, 2011, 12:53pm UTC](https://www.ruby-forum.com/t/upload-module-error/205091/6 "2011-03-29T12:53:04Z")

</div>

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/](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/](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/](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:  
[http://forum.nginx.org/read.php?2,186553,186579#msg-186579](http://forum.nginx.org/read.php?2,186553,186579#msg-186579)

---

<div class="post-metadata">

**Author:** ![vetri](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/3ab097/32.png) [@vetri](https://www.ruby-forum.com/u/vetri)\
**Post date:** [March 29, 2011, 3:18pm UTC](https://www.ruby-forum.com/t/upload-module-error/205091/7 "2011-03-29T15:18:12Z")

</div>

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:

> **[Re: upload module error](https://forum.nginx.org/read.php?2,186553,186610#msg-186610)**
>
> 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;

---

<div class="post-metadata">

**Author:** ![vetri](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/3ab097/32.png) [@vetri](https://www.ruby-forum.com/u/vetri)\
**Post date:** [March 29, 2011, 3:41pm UTC](https://www.ruby-forum.com/t/upload-module-error/205091/8 "2011-03-29T15:41:40Z")

</div>

----- vetri [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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.

---

<div class="post-metadata">

**Author:** ![vetri](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/3ab097/32.png) [@vetri](https://www.ruby-forum.com/u/vetri)\
**Post date:** [March 29, 2011, 5:52pm UTC](https://www.ruby-forum.com/t/upload-module-error/205091/9 "2011-03-29T17:52:30Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![vetri](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/3ab097/32.png) [@vetri](https://www.ruby-forum.com/u/vetri)\
**Post date:** [March 30, 2011, 6:00am UTC](https://www.ruby-forum.com/t/upload-module-error/205091/10 "2011-03-30T06:00:56Z")

</div>

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:

> **[Re: upload module error](https://forum.nginx.org/read.php?2,186553,186794#msg-186794)**
>
> 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;

---

<div class="post-metadata">

**Author:** ![vetri](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/3ab097/32.png) [@vetri](https://www.ruby-forum.com/u/vetri)\
**Post date:** [March 30, 2011, 6:37am UTC](https://www.ruby-forum.com/t/upload-module-error/205091/11 "2011-03-30T06:37:19Z")

</div>

mr yanxinz ,

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

Posted at Nginx Forum:

> **[Re: upload module error](https://forum.nginx.org/read.php?2,186553,186796#msg-186796)**
>
> 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;
