All files from this thread

File Name File Size   Posted by Date  
patch.static_post.1 16 KB open | download Igor Sysoev 05/27/2009 Read message
Maxim Dounin
January 29, 2010 05:10PM
Hello!

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

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

How to solve the problem of "405 not allowed"?

peacock May 27, 2009 03:17AM

Re: How to solve the problem of "405 not allowed"?

Dave Cheney May 27, 2009 03:28AM

Re: How to solve the problem of "405 not allowed"?

peacock May 27, 2009 04:37AM

Re: How to solve the problem of "405 not allowed"?

Rob Schultz May 27, 2009 04:56AM

Re: How to solve the problem of "405 not allowed"? Attachments

Igor Sysoev May 27, 2009 04:46AM

Re: How to solve the problem of "405 not allowed"?

peacock May 27, 2009 12:14PM

Re: How to solve the problem of "405 not allowed"?

Cliff Wells July 24, 2009 03:15PM

Re: How to solve the problem of "405 not allowed"?

Igor Sysoev July 24, 2009 03:25PM

Re: How to solve the problem of "405 not allowed"?

Jonathan Vanasco July 24, 2009 05:00PM

Re: How to solve the problem of "405 not allowed"?

peacock May 27, 2009 05:38AM

Re: How to solve the problem of "405 not allowed"?

Igor Sysoev May 27, 2009 11:07AM

Re: How to solve the problem of "405 not allowed"?

kleinchris January 29, 2010 11:41AM

Re: How to solve the problem of "405 not allowed"?

locojohn July 06, 2011 07:29PM

Re: How to solve the problem of "405 not allowed"?

locojohn July 07, 2011 09:25AM

Re: How to solve the problem of "405 not allowed"?

peacock July 28, 2009 11:44PM

RE: How to solve the problem of "405 not allowed"?

dennisjanuary October 08, 2009 10:56PM

Re: RE: How to solve the problem of "405 not allowed"?

kleinchris January 29, 2010 11:30AM

Re: RE: How to solve the problem of "405 not allowed"?

kleinchris January 29, 2010 05:58PM

Re: How to solve the problem of "405 not allowed"?

Nick Pearson January 29, 2010 02:34PM

Re: How to solve the problem of "405 not allowed"?

Maxim Dounin January 29, 2010 05:10PM

Re: How to solve the problem of "405 not allowed"?

Maxim Dounin January 29, 2010 05:16PM

Re: How to solve the problem of "405 not allowed"?

ahu October 06, 2011 12:21PM

Re: How to solve the problem of "405 not allowed"?

ahu October 06, 2011 12:35PM

Re: How to solve the problem of "405 not allowed"?

fernandokosh January 03, 2012 11:59AM

Re: How to solve the problem of "405 not allowed"?

goldenaxez March 29, 2012 04:25PM

Re: How to solve the problem of "405 not allowed"?

helluvanag .. September 10, 2013 03:30AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 182
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready