Discussion:
How to solve the problem of "405 not allowed"?
peacock
2009-05-27 07:17:49 UTC
Permalink
When I post when a JavaScript file, "405 not allowed" error will appear.

if use proxy, it can work.

error_page 405 =200 @405;
location @405 {
root /htdocs;
proxy_pass http://localhost:8080;
}


but I do not want to use proxy, just want to use Nginx, can to achieve it?

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,2414,2414#msg-2414
Dave Cheney
2009-05-27 07:28:39 UTC
Permalink
What response do you expect to receive when you issue

POST /javascript.js HTTP/1.1

Cheers

Dave
Post by peacock
When I post when a JavaScript file, "405 not allowed" error will appear.
if use proxy, it can work.
root /htdocs;
proxy_pass http://localhost:8080;
}
but I do not want to use proxy, just want to use Nginx, can to achieve it?
Posted at Nginx Forum: http://forum.nginx.org/read.php?2,2414,2414#msg-2414
peacock
2009-05-27 08:37:58 UTC
Permalink
sorry, my english is poor, I have listed some of the information


error_page 405 =200 @405;
location @405 {
root /htdocs;
#proxy_pass http://localhost:8080;
}


(ajax)POST:
http://localhost/....../index.js

Response:


405 Not Allowed

405 Not Allowed
nginx/0.7.59




Posted at Nginx Forum: http://forum.nginx.org/read.php?2,2414,2419#msg-2419
Rob Schultz
2009-05-27 08:56:45 UTC
Permalink
NginX does not allow posts to static content. But Igor has posted a
workaround
http://article.gmane.org/gmane.comp.web.nginx.english/1941/match=post+405+static

Rob Schultz
Post by peacock
sorry, my english is poor, I have listed some of the information
root /htdocs;
#proxy_pass http://localhost:8080;
}
http://localhost/....../index.js
405 Not Allowed
405 Not Allowed
nginx/0.7.59
Posted at Nginx Forum: http://forum.nginx.org/read.php?2,2414,2419#msg-2419
Igor Sysoev
2009-05-27 08:46:17 UTC
Permalink
Post by peacock
When I post when a JavaScript file, "405 not allowed" error will appear.
if use proxy, it can work.
root /htdocs;
proxy_pass http://localhost:8080;
}
but I do not want to use proxy, just want to use Nginx, can to achieve it?
Try the attached patch, it allows to POST to static files.
Probably I will include it in 0.8.0.
--
Igor Sysoev
http://sysoev.ru/en/
Cliff Wells
2009-07-24 19:15:37 UTC
Permalink
Post by Igor Sysoev
Post by peacock
When I post when a JavaScript file, "405 not allowed" error will appear.
if use proxy, it can work.
root /htdocs;
proxy_pass http://localhost:8080;
}
but I do not want to use proxy, just want to use Nginx, can to achieve it?
Try the attached patch, it allows to POST to static files.
Probably I will include it in 0.8.0.
Hi Igor,

I take it this patch not included?

Cliff
--
http://www.google.com/search?q=vonage+sucks
Igor Sysoev
2009-07-24 19:25:25 UTC
Permalink
Post by Cliff Wells
Post by Igor Sysoev
Post by peacock
When I post when a JavaScript file, "405 not allowed" error will appear.
if use proxy, it can work.
root /htdocs;
proxy_pass http://localhost:8080;
}
but I do not want to use proxy, just want to use Nginx, can to achieve it?
Try the attached patch, it allows to POST to static files.
Probably I will include it in 0.8.0.
Hi Igor,
I take it this patch not included?
No. Here is updated for 0.8.6 version.
--
Igor Sysoev
http://sysoev.ru/en/
Jonathan Vanasco
2009-07-24 21:00:55 UTC
Permalink
ah!
thanks.

i see a few threads for this title as "405"; i was searching POST
Post by Cliff Wells
Post by Igor Sysoev
Post by peacock
When I post when a JavaScript file, "405 not allowed" error will appear.
if use proxy, it can work.
root /htdocs;
proxy_pass http://localhost:8080;
}
but I do not want to use proxy, just want to use Nginx, can to achieve it?
Try the attached patch, it allows to POST to static files.
Probably I will include it in 0.8.0.
Hi Igor,
I take it this patch not included?
Cliff
--
http://www.google.com/search?q=vonage+sucks
peacock
2009-05-27 09:38:02 UTC
Permalink
Unfortunately, this workaround is still not working properly :(

Response:


500 Internal Server Error

500 Internal Server Error
nginx/0.7.59




Posted at Nginx Forum: http://forum.nginx.org/read.php?2,2414,2422#msg-2422
Igor Sysoev
2009-05-27 15:07:43 UTC
Permalink
Post by peacock
Unfortunately, this workaround is still not working properly :(
500 Internal Server Error
500 Internal Server Error
nginx/0.7.59
Could you create debug log of the request ?

./configure --with-debug ...

nginx.conf:

error_log /path/to/log debug;
--
Igor Sysoev
http://sysoev.ru/en/
kleinchris
2010-01-29 16:41:43 UTC
Permalink
Can't edit my post...
Here is a debug log, when i do it like this:
error_page 405 =200 @405;
location = @405 {
root /var/www/vhosts/soulreafer;
}

http://nopaste.info/5cf44ab3b1.html

nginx version: 0.8.32

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,2414,47301#msg-47301
Nick Pearson
2010-01-29 19:30:16 UTC
Permalink
I know 'if' is evil, and in general shouldn't be used inside a
location block, but I needed this ability as well and have been using
the following without any trouble for a couple years.

upstream app_servers {
server localhost:3000;
}

server {

# set proxy settings here (not allowed in 'if')
proxy_set_header X-Real-IP $remote_addr;

location / {
if ($request_method = POST) {
proxy_pass http://app_servers;
break;
}
try_files $uri @app;
}

location @app {
proxy_pass http://app_servers;
}

}

If anyone has any better ideas, I'd love to hear them. So far, I
haven't been able to find any without having to patch the source.

While we're on the topic, I know there's been talk of allowing POST
requests to static files, but I don't remember a clear behavior being
defined. When added to nginx, will this simply serve the static file
as though a GET request was made? Ideally, one would be able to
specify that POST requests should always be proxied to an upstream
(which is what my config above does).

Maybe something like this in the config:

# handle just like a GET request
allow_static_post on;

# proxy to upstream
allow_static_post proxy_pass http://app_servers;

I don't use FCGI or PHP, so I'm not sure how the config would look for
those, but you get the idea.

Nick
Post by kleinchris
Can't edit my post...
               root /var/www/vhosts/soulreafer;
       }
http://nopaste.info/5cf44ab3b1.html
nginx version: 0.8.32
Posted at Nginx Forum: http://forum.nginx.org/read.php?2,2414,47301#msg-47301
_______________________________________________
nginx mailing list
http://nginx.org/mailman/listinfo/nginx
Maxim Dounin
2010-01-29 22:04:16 UTC
Permalink
Hello!
Post by Nick Pearson
I know 'if' is evil, and in general shouldn't be used inside a
location block, but I needed this ability as well and have been using
the following without any trouble for a couple years.
upstream app_servers {
server localhost:3000;
}
server {
# set proxy settings here (not allowed in 'if')
proxy_set_header X-Real-IP $remote_addr;
location / {
if ($request_method = POST) {
proxy_pass http://app_servers;
break;
}
}
proxy_pass http://app_servers;
}
}
If anyone has any better ideas, I'd love to hear them. So far, I
haven't been able to find any without having to patch the source.
The above configuration will work, but expect problems once you'll
add another if. I personally suggest something like:

location / {
error_page 405 = @app;
try_files $uri @app;
}

location @app {
proxy_pass http://app_servers;
}

As static module will return 405 for POST request this is
mostly identical to what you currently has (though it will also
pass to app servers other methods unknown to static module, e.g.
PUT).
Post by Nick Pearson
While we're on the topic, I know there's been talk of allowing POST
requests to static files, but I don't remember a clear behavior being
defined. When added to nginx, will this simply serve the static file
as though a GET request was made? Ideally, one would be able to
specify that POST requests should always be proxied to an upstream
(which is what my config above does).
# handle just like a GET request
allow_static_post on;
# proxy to upstream
allow_static_post proxy_pass http://app_servers;
I don't use FCGI or PHP, so I'm not sure how the config would look for
those, but you get the idea.
I see no problem using error_page to handle this.

Maxim Dounin
Maxim Dounin
2010-01-29 22:12:45 UTC
Permalink
Hello!
Post by kleinchris
Can't edit my post...
root /var/www/vhosts/soulreafer;
}
This will return internal 405 error page, as

1. you are serving request by static module again;

2. error_page to named location doesn't change request method.

Try this instead:

error_page 405 = $uri;

This way request method will be changed to GET, and the same uri
will be used to serve it.
Post by kleinchris
http://nopaste.info/5cf44ab3b1.html
This log doesn't shows any problems, and it's not even for POST
request. Instead it shows perfectly ok GET request (returning 304
not modified, as request includes If-Modified-Since).

Maxim Dounin
locojohn
2011-07-06 23:29:27 UTC
Permalink
Unfortunately, I too am getting the 405 response from the SiteSupra CMS
management system when running in the admin mode:

"POST /index.php/supra/block/en/scale.php?SCALE/16100 HTTP/1.1" 405 754


However, this is a PHP script, so why does it give the 405 status?

Many thanks for suggestions

Andrejs

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,2414,211998#msg-211998
locojohn
2011-07-07 13:25:36 UTC
Permalink
In my case problem was solved, as it was incorrect rewrite rule and the
PHP script never received control, hence - 405. May I suggest that all
who receive 405 responses first check whether rewrite rules are
correctly configured.

Andrejs

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,2414,212003#msg-212003
peacock
2009-05-27 16:14:44 UTC
Permalink
Post by Igor Sysoev
Try the attached patch, it allows to POST to
static files.
Probably I will include it in 0.8.0.
--
Igor Sysoev
http://sysoev.ru/en/
I'm sorry, I do not see your reply:)

I use Windows, so I do not know how to run the patch.

Hope to be able to add this feature 0.8.0:)

thank you very much!

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,2414,2426#msg-2426
peacock
2009-07-29 03:44:32 UTC
Permalink
Unfortunately, so far(0.8.7), not to solve this problem :(

I read the source code, ngx_http_static_module.c documents found this piece of code inside

if (r->method & NGX_HTTP_POST) {
return NGX_HTTP_NOT_ALLOWED;
}


Posted at Nginx Forum: http://forum.nginx.org/read.php?2,2414,4549#msg-4549
dennis cao
2009-10-09 02:49:50 UTC
Permalink
<20090527084617.GD60957-***@public.gmane.org>
Content-Type: text/plain; charset="big5"
Content-Transfer-Encoding: 8bit
MIME-Version: 1.0


Is this patch build-in in the new version?
Date: Wed, 27 May 2009 12:46:17 +0400
Subject: Re: How to solve the problem of "405 not allowed"?
Post by peacock
When I post when a JavaScript file, "405 not allowed" error will appear.
if use proxy, it can work.
root /htdocs;
proxy_pass http://localhost:8080;
}
but I do not want to use proxy, just want to use Nginx, can to achieve it?
Try the attached patch, it allows to POST to static files.
Probably I will include it in 0.8.0.
--
Igor Sysoev
http://sysoev.ru/en/
_________________________________________________________________
€Užü Windows Live Messenger 9.0¡AŠh€ž·Ÿ³q¡BºÉ±¡€ÀšÉ¡A©M§Y®É¶Ç°TŠn€Íœu€WŠPŒÖ¡I¡X ¥ß§Y€Užü
http://download.live.com/messenger
kleinchris
2010-01-29 16:30:12 UTC
Permalink
Is there a fix that I can POST on static files in nginx 0.8.32? I need this..

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,2414,47294#msg-47294
kleinchris
2010-01-29 22:58:16 UTC
Permalink
Hm very bad to proxy, I manually applied the patch that were postet. And finally it will works.
One File I needed to edit manually, but know Igor's Patch is working.

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,2414,47475#msg-47475
ahu
2011-10-06 16:21:37 UTC
Permalink
I find this problem occurs when enable fastcgi cache with php
sometime.The nginx just treat php files as static files :(

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,2414,216323#msg-216323
ahu
2011-10-06 16:35:24 UTC
Permalink
ahu Wrote:
-------------------------------------------------------
Post by ahu
I find this problem occurs when enable fastcgi
cache with php sometime.The nginx just treat php
files as static files :(
p.s. I use nginx 1.1.5

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,2414,216325#msg-216325
fernandokosh
2012-01-03 16:59:52 UTC
Permalink
I have the same issue here running Rails 2 apps virtual hosts on Debian
Squeeze.
In my case I, the error occur when I perform update with the PUT
method.
That's solve my problem:

location / {
error_page 405 = $uri;
try_files $uri @unicorn_app;
}

Thank you!

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,2414,220771#msg-220771
goldenaxez
2012-03-29 20:25:35 UTC
Permalink
fernandokosh Wrote:
-------------------------------------------------------
Post by fernandokosh
I have the same issue here running Rails 2 apps
virtual hosts on Debian Squeeze.
In my case I, the error occur when I perform
update with the PUT method.
location / {
error_page 405 = $uri;
}
Thank you!
Hello fernandokosh,
Thank you for your post. I tried really works.But this time I'm getting
a 500 internal server error. My site not open the directly.
I have to open www.vantila.com/index.html.

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,2414,224626#msg-224626
helluvanag ..
2013-09-10 07:28:09 UTC
Permalink
Hi,
In all the above posts a code snippet has been given to rectify the
405 error. But i wondering where exactly that code snippet has to be
added(i mean in which file of the server box). If anyone can explain a
bit elaborately, i would be grateful.

Thanks and Regards,
Nagender
--
Posted via http://www.ruby-forum.com/.
Continue reading on narkive:
Loading...