title: Puppet nginx vhost with php support
body: <p>I have created a custom resource to add vhosts with direct php support.
  The vhost is created and the custom location is added but if i try it it downloads all the files instead of processing them.</p>
  
  <p>What am i missing?
  <a href="https://github.com/jfryman/puppet-nginx/" rel="nofollow">https://github.com/jfryman/puppet-nginx/</a> is the module that i use.</p>
  
  <p>The pp file:</p>
  
  <pre><code>$full_web_path = '/var/www'
  
  define web::nginx_php_vhost (
    $backend_port         = 9000,
    $php                  = true,
    $proxy                = undef,
    $www_root             = "${full_web_path}/${name}/",
    $location_cfg_append  = undef,
  ) {
    nginx::resource::vhost { "${name}.${::domain} ${name}":
      ensure                =&gt; present,
      listen_port           =&gt; 80,
      www_root              =&gt; $www_root,
      owner                  =&gt; 'evancauwenberg',
      group                  =&gt; 'www-data',
      mode                   =&gt; '0755',
      access_log            =&gt; "/var/log/nginx/${name}_access.log",
      error_log             =&gt; "/var/log/nginx/${name}_error.log",
      location_cfg_append   =&gt; {
        try_files =&gt; '$uri $uri/ =404'
      },
      index_files           =&gt; [ 'index.php' ],
    }
  
    if $php {
      nginx::resource::location { "${name}_root":
        ensure          =&gt; present,
        vhost           =&gt; "${name}.${::domain} ${name}",
        www_root        =&gt; $www_root,
        location        =&gt; '~ \.php$',
        index_files     =&gt; ['index.php', 'index.html', 'index.htm'],
        proxy           =&gt; undef,
        fastcgi         =&gt; "127.0.0.1:${backend_port}",
        fastcgi_script  =&gt; undef,
        location_cfg_append =&gt; {
          fastcgi_split_path_info =&gt; '^(.+\.php)(/.+)$',
          fastcgi_index =&gt; 'index.php',
          fastcgi_connect_timeout =&gt; '3m',
          fastcgi_read_timeout    =&gt; '3m',
          fastcgi_send_timeout    =&gt; '3m'
        }
      }
    }
  }
  
  
  web::nginx_php_vhost { "evert.be":
    www_root =&gt; "/var/www/evert.be",
  }
  </code></pre>
  
  <p>The created vhost:</p>
  
  <pre><code>server {
    listen                *:80;
  
    server_name           evert.be;
  
      index  index.php;
  
    access_log            /var/log/nginx/evert_access.log;
    error_log             /var/log/nginx/evert_error.log;
  
    location ~ \.php$ {
  
      root  /var/www/evert/evert.be;
      include /etc/nginx/fastcgi_params;
      fastcgi_pass 127.0.0.1:9000;
  
      fastcgi_connect_timeout 3m;
      fastcgi_index index.php;
      fastcgi_read_timeout 3m;
      fastcgi_send_timeout 3m;
      fastcgi_split_path_info ^(.+\.php)(/.+)$;;
    }
    location / {
  
      root  /var/www/evert/evert.be;
      try_files $uri $uri/ =404;
    }
  }
  </code></pre>