title: Nginx nested location with route rewrite
body: <p>I would like to nest several dedicated routes within a site to specific directories which might not have the same name.  I can't figure out how to do a rewrite of the path it uses for the <code>try_files</code>.</p>
  
  <pre><code>server {           
      listen 80 default_server;
      listen [::]:80 default_server;
  
      root /var/www/default;
  
      index index.html;
  
      server_name _;
  
      if ($bad_referer) {
          return 444;
      }
  
      location / {
          try_files $uri $uri/ =404;
      }
  
      location /postfixadmin/ {
          access_log /var/log/nginx/postfixadmin/access.log;
          error_log /var/log/nginx/postfixadmin/error.log;
  
          root /var/www/postfixadmin/;
          index index.php index.html index.htm;
          try_files $uri $uri/ /index.php;
  
  
          location ~ \.php$ {
              include fastcgi.conf;
              fastcgi_index index.php;
              fastcgi_intercept_errors on;
              fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
          }
  
          location ~* \.(css|js|gif|jpe?g|png|woff|woff2|ttf|eot|svg|ico)$ {
              expires 168h;
              add_header Pragma public;
              add_header Cache-Control "public, must-revalidate, proxy-revalidate";
          }
      }
  
      location /email/ {
  
          #access_log /var/log/nginx/roundcube/access.log;
          #error_log /var/log/nginx/roundcube/error.log;
  
          root /var/www/roundcube/;
          index index.php index.html index.htm;
          try_files $uri $uri/ /index.php;
  
          location ~ \.php$ {
              include fastcgi.conf;
              fastcgi_index index.php;
              fastcgi_intercept_errors on;
              fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
          }
  
          location ~* \.(css|js|gif|jpe?g|png|woff|woff2|ttf|eot|svg|ico)$ {
              expires 168h;
              add_header Pragma public;
              add_header Cache-Control "public, must-revalidate, proxy-revalidate";
          }
      }
  }
  </code></pre>
  
  <p>When I navigate to <code>www.site.com/email</code>, I receive a <code>404</code>, and I'm assuming that is because it's looking for <code>/var/www/roundcube/email/index.php</code>, which doesn't exist.  What do I need to do to rewrite the file path before the <code>try_files</code>?</p>