Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nginx vhost with php support #416

Closed
evancauwenberg opened this issue Aug 21, 2014 · 1 comment
Closed

Nginx vhost with php support #416

evancauwenberg opened this issue Aug 21, 2014 · 1 comment

Comments

@evancauwenberg
Copy link

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.

What am i missing?
https://github.com/jfryman/puppet-nginx/ is the module that i use.

The pp file:

$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                => present,
    listen_port           => 80,
    www_root              => $www_root,
    owner                  => 'evancauwenberg',
    group                  => 'www-data',
    mode                   => '0755',
    access_log            => "/var/log/nginx/${name}_access.log",
    error_log             => "/var/log/nginx/${name}_error.log",
    location_cfg_append   => {
      try_files => '$uri $uri/ =404'
    },
    index_files           => [ 'index.php' ],
  }

  if $php {
    nginx::resource::location { "${name}_root":
      ensure          => present,
      vhost           => "${name}.${::domain} ${name}",
      www_root        => $www_root,
      location        => '~ \.php$',
      index_files     => ['index.php', 'index.html', 'index.htm'],
      proxy           => undef,
      fastcgi         => "127.0.0.1:${backend_port}",
      fastcgi_script  => undef,
      location_cfg_append => {
        fastcgi_split_path_info => '^(.+\.php)(/.+)$',
        fastcgi_index => 'index.php',
        fastcgi_connect_timeout => '3m',
        fastcgi_read_timeout    => '3m',
        fastcgi_send_timeout    => '3m'
      }
    }
  }
}


web::nginx_php_vhost { "evert.be":
  www_root => "/var/www/evert.be",
}

The created vhost:

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;
  }
}
@evancauwenberg
Copy link
Author

Fixed the problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant