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 set both location_alias and fastcgi at the same time on a location #591

Closed
alex-barylski opened this issue Apr 2, 2015 · 5 comments
Labels
bug Something isn't working

Comments

@alex-barylski
Copy link

I have the following:

  nginx::resource::vhost { 'aerospace':
    ensure                => present,

    www_root              => '/usr/share/nginx/html',
    server_name           => ['apps.cadorath.local'],

    index_files           => ['index.php', 'index.html'],

    fastcgi     => 'unix:/var/run/php5-fpm.sock',
  }

  nginx::resource::location { 'application':
    vhost => 'aerospace',

    ensure  => present,
    location => '~ [^/]\.php(/|$)',
    location_alias => '/usr/share/nginx/html/application',

    fastcgi_split_path => '^(.+>\.php)(/.*)$',
    fastcgi_param  => {
      'MYDOMAIN_FQDN' => 'http://apps.mydomain.local',
    }
  } 

This is the resulting file in .../sites-enabled

server {
  listen *:80;
  server_name           apps.cadorath.local;

  set $maintenance "off";
  if ($maintenance = "on") {
      return 503;
  }
  index  index.php index.html;

  access_log            /var/log/nginx/aerospace.access.log combined;
  error_log             /var/log/nginx/aerospace.error.log;

  location ~ [^/]\.php(/|$) {
    alias /usr/share/nginx/html/application;
  }

  location / {
    root          /usr/share/nginx/html;
    include       /etc/nginx/fastcgi_params;

    fastcgi_pass  unix:/var/run/php5-fpm.sock;
  }
}

Why is split_path and param not being echo'ed to the resulting file -- no errors as far as I can tell. What am I missing???

Alex

@3flex
Copy link
Contributor

3flex commented Apr 2, 2015

Hi @alex-barylski

You're not doing anything wrong here, the module doesn't currently support this (but a PR to improve things here would definitely be appreciated!)

The relevant code is here: https://github.com/jfryman/puppet-nginx/blob/master/manifests/resource/location.pp#L323-L336

You've specified both location_alias and fastcgi for your location, and location_alias is taking precedence when the module selects a template to render for the location block.

In the meantime you can use location_alias then set your fastcgi parameters using location_cfg_prepend and/or location_cfg_append or similar.

@3flex 3flex changed the title vhost location and fastcgi_param not generating??? Cannot set both location_alias and fastcgi at the same time on a location Apr 2, 2015
@alex-barylski
Copy link
Author

I would love to help...unfortunately I am totally new to Puppet so I doubt I could contribute anything of value -- just questions for now :) I will try your suggested solution -- thank you for the quick response.

@3flex
Copy link
Contributor

3flex commented Apr 2, 2015

Let's leave this open. It's still a valid issue even if you're not up to submitting a PR to address it!

@3flex 3flex reopened this Apr 2, 2015
@wyardley wyardley added the bug Something isn't working label Oct 13, 2016
@wyardley
Copy link
Collaborator

wyardley commented Nov 14, 2016

#966 and @xaque208's #970 are a step in the right direction here, and I think #970 may allow this, specifically in https://github.com/voxpupuli/puppet-nginx/blob/master/templates/vhost/location.erb#L2-L7

If this is still an issue, or if you have time, @alex-barylski, could you try testing current git master and see if the behavior is more along the lines of what you were thinking? We'll be cutting a release soon as well.

@wyardley
Copy link
Collaborator

wyardley commented Dec 5, 2016

I believe this should be fixed, since no one has tested / verified still, I'm going to close this for now, let's open a new issue if there are additional problems, though I would like to do a better rework of this logic at some point.

@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
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants