title: variable capture in Nginx location matching
body: <p>Let's say I have a URL like this: <code>www.example.com/a/b/sth</code>, and I write a location block in Nginx config:</p>
  
  <pre><code>location ^~ /a/b/(?&lt;myvar&gt;[a-zA-Z]+) {
      # use variable $myvar here
      if ($myvar = "sth") { ... }
  }
  </code></pre>
  
  <p>I hope to be able to use variable <code>$myvar</code> captured from the URL <em>inside</em> the block, however, Nginx keeps telling me this variable is not defined and won't start:</p>
  
  <pre><code>nginx: [emerg] unknown "myvar" variable
  </code></pre>