title: Reuse configuration statements for domains in nginx.conf
body: <p>Let's say I have a nginx configuration set up for a domain like this:</p>
  
  <pre><code>server {
  
    root /path/to/one;
    server_name one.example.org;
  
    location ~ \.php$ {
      try_files       $uri =404;
      fastcgi_pass    127.0.0.1:9000;
      fastcgi_index   index.php;
      fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
      include         fastcgi_params;
    }
  
  }
  </code></pre>
  
  <p>Now, if I want to add another domain with different content, is there a way I can re-use equivalent statements from the previous domain, or do I have to duplicate everything for every new domain I want to support?</p>
  
  <pre><code>server {
  
    root /path/to/two; # different
    server_name two.example.org; # different
  
    location ~ \.php$ {
      try_files       $uri =404;
      fastcgi_pass    127.0.0.1:9000;
      fastcgi_index   index.php;
      fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
      include         fastcgi_params;
    }
  
  }
  </code></pre>
  
  <p>I tried moving the <code>location</code> directive outside the <code>server</code> closure, but obviously things don't work like that because I got an error "location directive is not allowed here" when restarting nginx.</p>