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

cannot create location with only try_files defined #470

Closed
buckstr opened this issue Oct 7, 2014 · 3 comments · Fixed by #834
Closed

cannot create location with only try_files defined #470

buckstr opened this issue Oct 7, 2014 · 3 comments · Fixed by #834
Labels
enhancement New feature or request

Comments

@buckstr
Copy link

buckstr commented Oct 7, 2014

The check for creating a resource does not check to see if try_files is defined which alone could be used to create a valid location reference.

For example in wordpress if you want to forward rewrites to index.php you would need the following

location / {
  try_files $uri $uri/ /index.php?$args;
}
@buckstr
Copy link
Author

buckstr commented Oct 7, 2014

#471

@schkovich
Copy link

Actually you can do it using location_custom_cfg:

nginx::nginx_locations:
  try:
    location: '/'
    vhost: 'www.yourdomain.dev'
    location_custom_cfg:
      try_files: '$uri $uri/ /index.php?$args'

resulting in:

  location / {
    try_files $uri $uri/ /index.php?$args;
  }

FlorianSW added a commit to FlorianSW/puppet-nginx that referenced this issue Jul 19, 2016
This is already possible through location_custom_cfg with a manifest
that looks like:

nginx::resource::location { 'location name':
  location  => '/',
  vhost     => 'any vhost',
  location_custom_cfg => {
    'try_files' => '$uri $uri/ @rewrite',
  }
}

This change simplifies the part by allowing to use the try_files
directive on its own (without only in combination with, e.g., www_root):

nginx::resource::location { 'location name':
  location  => '/',
  vhost     => 'any vhost',
  try_files' => [ '$uri', '$uri/', '@rewrite' ],
}

That looks a bit better as know the user doesn't need to think about,
if he can use try_files or need to use location_custom_cfg in the current
context, anymore.

fixes voxpupuli#470
@FlorianSW
Copy link
Contributor

#834 implements a possible solution, however, I'm not so happy with it at all. The main reason is, that there're some other valid cases, where only one other directive is possible, too, such as rewrite. Maybe we should take this into account and create a separate template for these valid cases on it's own? Such as the empty.erb but without the location_custom_cfg processing and a set of valid other options (try_files, rewrite, ... (are there any more?)). Ideas? Opinions?

darken99 pushed a commit to darken99/puppet-nginx that referenced this issue Oct 13, 2016
This is already possible through location_custom_cfg with a manifest
that looks like:

nginx::resource::location { 'location name':
  location  => '/',
  vhost     => 'any vhost',
  location_custom_cfg => {
    'try_files' => '$uri $uri/ @rewrite',
  }
}

This change simplifies the part by allowing to use the try_files
directive on its own (without only in combination with, e.g., www_root):

nginx::resource::location { 'location name':
  location  => '/',
  vhost     => 'any vhost',
  try_files' => [ '$uri', '$uri/', '@rewrite' ],
}

That looks a bit better as know the user doesn't need to think about,
if he can use try_files or need to use location_custom_cfg in the current
context, anymore.

fixes voxpupuli#470
cegeka-jenkins pushed a commit to cegeka/puppet-nginx that referenced this issue Sep 13, 2019
This is already possible through location_custom_cfg with a manifest
that looks like:

nginx::resource::location { 'location name':
  location  => '/',
  vhost     => 'any vhost',
  location_custom_cfg => {
    'try_files' => '$uri $uri/ @rewrite',
  }
}

This change simplifies the part by allowing to use the try_files
directive on its own (without only in combination with, e.g., www_root):

nginx::resource::location { 'location name':
  location  => '/',
  vhost     => 'any vhost',
  try_files' => [ '$uri', '$uri/', '@rewrite' ],
}

That looks a bit better as know the user doesn't need to think about,
if he can use try_files or need to use location_custom_cfg in the current
context, anymore.

fixes voxpupuli#470
Rubueno pushed a commit to Rubueno/puppet-nginx that referenced this issue Oct 19, 2020
This is already possible through location_custom_cfg with a manifest
that looks like:

nginx::resource::location { 'location name':
  location  => '/',
  vhost     => 'any vhost',
  location_custom_cfg => {
    'try_files' => '$uri $uri/ @rewrite',
  }
}

This change simplifies the part by allowing to use the try_files
directive on its own (without only in combination with, e.g., www_root):

nginx::resource::location { 'location name':
  location  => '/',
  vhost     => 'any vhost',
  try_files' => [ '$uri', '$uri/', '@rewrite' ],
}

That looks a bit better as know the user doesn't need to think about,
if he can use try_files or need to use location_custom_cfg in the current
context, anymore.

fixes voxpupuli#470
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
4 participants