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

www_root is not being added correctly #639

Closed
SoldierCorp opened this issue Jun 7, 2015 · 5 comments
Closed

www_root is not being added correctly #639

SoldierCorp opened this issue Jun 7, 2015 · 5 comments

Comments

@SoldierCorp
Copy link

I'm working with puppet, capistrano and other technologies to make a deployment structure using Laravel but I have a problem using the nginx puppet because I want to know why the www_root is not being adding outside a location like the index_files parameter because inside a location is not working. And if it's not working couldn't work correctly with my deployment.

Conf

class { 'nginx':  }

nginx::resource::vhost { $vhost:
  ensure => present,
  www_root => $docroot,
  index_files => [ 'index.php' ],
  location_cfg_append => {
    'rewrite' => '^/(.+)/$ /$1 permanent',
    'try_files $uri $uri/' => '/index.php?query_string'
  }
}

nginx::resource::location { $vhost:
  ensure          => present,
  vhost           => $vhost,
  www_root        => $docroot,
  location        => '~ \.php$',
  index_files     => ['index.php', 'index.html', 'index.htm'],
  proxy           => undef,
  fastcgi         => "127.0.0.1:9000",
  fastcgi_script  => undef,
  location_cfg_append => {
    fastcgi_index   => ['index.php']
  },
  fastcgi_param  => {
    'SCRIPT_FILENAME' => '$document_root$fastcgi_script_name'
  },

}

Not working

server {
  listen *:80;
  server_name           local.example.com;

  index  index.php;

  access_log            /var/log/nginx/example.com.access.log combined;
  error_log             /var/log/nginx/example.com.error.log;

  location / {
    root      /var/www/ratestore/src/public/;
    rewrite ^/(.+)/$ /$1 permanent;
    try_files $uri $uri/ /index.php?query_string;
  }
  ....
}

Working

server {
  listen *:80;
  server_name           local.example.com;

  root      /var/www/ratestore/src/public/;

  index  index.php;

  access_log            /var/log/nginx/example.com.access.log combined;
  error_log             /var/log/nginx/example.com.error.log;

  location / {
    rewrite ^/(.+)/$ /$1 permanent;
    try_files $uri $uri/ /index.php?query_string;
  }

  .....

}
@SoldierCorp SoldierCorp changed the title www_root of nginx puppet is not being added correctly www_root is not being added correctly Jun 7, 2015
@sirgt
Copy link

sirgt commented Jun 19, 2015

I'm having the same problem, root inside location doesn't work.

Temporarily I fixed this on my puppet server like this

@michaelmeelis
Copy link

I have the same problem using this module too install Laravel as well. It would be great if this can be resolved.

@jassik
Copy link

jassik commented Jul 16, 2015

@SoldierCorp You need to set use_default_location => false for the module to add root /var/www/ratestore/src/public/; outside the location blocks, in your vhost resource declaration. This will also disable creation of the "location /" block by default in your vhost. So now you also need to declare another location resource for your default location / , something like this:

nginx::resource::location { "${vhost}_default":
  ensure          => present,
  vhost             => $vhost,
  #www_root        => $docroot, #not sure why this is not working for your default case
  location         => '/',
  rewrite_rules => ["^/(.+)/$ /$1 permanent"],
  try_files         => ["$uri", "$uri/", "/index.php?query_string"],
  ....

@wyardley
Copy link
Collaborator

I opened #902 recently about the same issue. I do think the behavior is somewhat improved now (there's an error, just not a useful one), but I hope we can improve this.

@wyardley
Copy link
Collaborator

wyardley commented Dec 5, 2016

Closing this since #902 is open.

@wyardley wyardley closed this as completed Dec 5, 2016
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

5 participants