Is this patch build-in in the new version?
> Date: Wed, 27 May 2009 12:46:17 +0400
> From: i...@rambler-co.ru
> To: ng...@sysoev.ru
> Subject: Re: How to solve the problem of "405 not allowed"?
>
> On Wed, May 27, 2009 at 03:17:49AM -0400, peacock wrote:
>
>> 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?
>
> 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/
_________________________________________________________________
下載 Windows Live Messenger 9.0,多元溝通、盡情分享,和即時傳訊好友線上同樂!— 立即下載
http://download.live.com/messenger
Posted at Nginx Forum: http://forum.nginx.org/read.php?2,2414,47294#msg-47294
_______________________________________________
nginx mailing list
ng...@nginx.org
http://nginx.org/mailman/listinfo/nginx
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
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
On Fri, Jan 29, 2010 at 01:30:16PM -0600, Nick Pearson wrote:
> 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.
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).
> 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.
I see no problem using error_page to handle this.
Maxim Dounin
On Fri, Jan 29, 2010 at 11:41:43AM -0500, kleinchris wrote:
> 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;
> }
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.
> 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
Posted at Nginx Forum: http://forum.nginx.org/read.php?2,2414,47475#msg-47475
"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
Andrejs
Posted at Nginx Forum: http://forum.nginx.org/read.php?2,2414,212003#msg-212003
Posted at Nginx Forum: http://forum.nginx.org/read.php?2,2414,216323#msg-216323
_______________________________________________
nginx mailing list
ng...@nginx.org
p.s. I use nginx 1.1.5
Posted at Nginx Forum: http://forum.nginx.org/read.php?2,2414,216325#msg-216325
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
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