title: nginx alternative for proxy_pass directive within if statement
body: <p>I've got the following NGINX configuration:</p>
  
  <pre><code>- location /concepts {
    auth_basic "off";
    if ($http_accept ~ 'application/json') { set $isapirequest "true"; }
    if ($http_accept ~ 'application/ld\+json') { set $isapirequest "true"; }
    if ($http_accept ~ 'application/hal\+json') { set $isapirequest "true"; }
    if ( $isapirequest = "true" ) { proxy_pass http://127.0.0.1:5315/search/concepts/; }
    if ( $isapirequest != "true" ) {
    rewrite ^/concepts$ /concepts/ redirect;
    rewrite ^(.*)$ /blah$1 last;
    }
    include add_cors_headers_OPTIONS_HEAD_GET_PUT_DELETE;
    }
  </code></pre>
  
  <p>The error that I'm getting is:</p>
  
  <pre><code>\"proxy_pass\" cannot have URI part in location given by regular expression, or inside named location, or inside \"if\" statement, or inside \"limit_except\"
  </code></pre>
  
  <p>Can you guys think of any way on NGINX to achieve the above without using an "if" statement?</p>