title: Nginx process upper level directives
body: <p>I'm configuring my nginx server with fpm-php and getting some trouble:</p>
  
  <p>I want nginx to apply some directives defined in "upper level" locations and also more precise locations.  I'll explain myself:</p>
  
  <pre><code>/admin {
    # apply auth-basic directives
  }
  
  location ~* \.php$ {
    # apply fpm-php proxy directives (php processing)
  }
  </code></pre>
  
  <p>I want URL
  /admin/example.php</p>
  
  <p>to process both directives, so authorization and php processing both apply.  But as per location precedence on nginx first, any regular expression takes precedence over prefix locations, resulting in no auth-basic directives been applied.</p>
  
  <p>I've managed to get this working including the upper level config inside the other location:</p>
  
  <pre><code>/admin {
      # apply auth-basic directives
      # apply fpm-php proxy directives (php processing)
  }
  
  location ~* /admin/(.*)\.php$ {
      # apply auth-basic directives
  }
  
  location ~* \.php$ {
      # apply fpm-php proxy directives (php processing)
  }
  </code></pre>
  
  <p>But I think this is againt DRY (Don't Repeat Yourself) and quite uncomfortable :(  Even using include directive.</p>
  
  <p>Do you know any better way of doing this?</p>
  
  <p>Thanks guys! ^_^</p>