<div><br></div>To follow up on my own question:<div><br></div><div>Maxim Dounin, in response to another question in the forum, recommended this version to get a very similar effect and avoid the if:<div><br></div><div><div>

    location / {</div><div>      # static handler returns 405 for POST and PUT requests to a static file                                                                                                                     </div>

<div>      error_page 405 = @sinatra;</div><div>      try_files $uri $uri/index.html $uri.html @sinatra;</div><div>    }</div><div><br></div><div>    location @sinatra {</div><div>      ...</div><div>      proxy_pass <a href="http://app_servers">http://app_servers</a>;</div>

<div>    }</div><div><br></div><div><br></div><br><div class="gmail_quote">On Thu, Dec 2, 2010 at 12:55 PM, Aaron Starr <span dir="ltr">&lt;<a href="mailto:astarr@wiredquote.com">astarr@wiredquote.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div><br></div>Hello, all,<div><br></div><div>I would like to configure nginx to return a file if the request method is GET. But, if the request method is PUT or POST, I&#39;d like for the back end to handle it. So, ideally, something like this:</div>


<div><br></div><div><div>    location / GET {</div><div>      try_files $uri $uri/index.html $uri.html @missing;</div><div>    }</div><div>    </div><div>    location / PUT {</div><div>      proxy_pass <a href="http://sinatra" target="_blank">http://sinatra</a>;</div>


<div>      ....</div><div>    }</div><div><br></div><div>    location @missing {</div><div>      return 404;</div><div>    }</div><div><br></div></div><div>I understand that that particular syntax isn&#39;t possible. Is something like this the best way to do it?</div>


<div><br></div><div><div>    location / {</div><div><br></div><div>      if ($request_method = PUT) {</div><div>        proxy_pass <a href="http://sinatra" target="_blank">http://sinatra</a>;</div><div>        ....</div>

<div>        break;</div>
<div>      }</div><div><br></div><div>      try_files $uri $uri/index.html $uri.html @missing;</div><div>    }</div><div><br></div><div>    location @missing {</div><div>      return 404;</div><div>    }</div></div><div>

<br>
</div><div>I&#39;m aware that if==bad, but not sure if there&#39;s a better way to redirect traffic based on the request method?</div><div><br></div><div>Thanks for any help,</div><div><br></div><font color="#888888"><div>

Aaron</div><div><br></div>
</font></blockquote></div><br></div></div>