title: nginx. Test which location used to process request
body: <p>I'm wondering how do I know if a particular location[s] used to process request in <code>nginx</code>.</p>
  
  <p>E.g.:</p>
  
  <pre><code># 1
  location / {}
  
  # 2
  location ~ /[\w\-]+\.html {}
  
  # 3
  location ~ /\w+\.html {}
  </code></pre>
  
  <p>How do I know if URI like <code>/mysite</code> is processed by 3rd location and not 2nd?
  I tend to use <a href="http://nginx.org/en/docs/http/ngx_http_headers_module.html#add_header" rel="noreferrer"><code>add_header</code></a> for this matter:</p>
  
  <pre><code>location / {
      add_header location 1;
  }
  
  location ~ /(\w+\-)\.html {
      add_header location 2;    
  }
  
  location @named {
      add_header location named;
  }
  </code></pre>
  
  <p>And I'd like to know is there a better solution or what do you personally use for debugging purposes?</p>