<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'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">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'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">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'm aware that if==bad, but not sure if there'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><div>Aaron</div><div><br>
</div>