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

Add more complex examples #872

Open
c33s opened this issue Sep 5, 2016 · 2 comments
Open

Add more complex examples #872

c33s opened this issue Sep 5, 2016 · 2 comments

Comments

@c33s
Copy link
Member

c33s commented Sep 5, 2016

one thing is missing for this awesome module, a better documentation of complex examples.

the mini examples are quite nice to get a quick overview but for easy an fast usage of this module it would be good to also have complex examples. they should be available as puppetcode and hiera examples.

having a simple profile::nginx i am try to get a hiera config for symfony2 up and running.

class profile::nginx {
  class { 'nginx': }
  $vhosts = lookup('profile::nginx::vhosts', Hash)|$vhosts| { {} }
  $locations = lookup('profile::nginx::locations', Hash)|$locations| { {} }
  create_resources('nginx::resource::vhost', $vhosts)
  create_resources('nginx::resource::location', $locations)
server {
    server_name domain.tld www.domain.tld;
    root /var/www/project/web;

    location / {
        # try to serve file directly, fallback to app.php
        try_files $uri /app.php$is_args$args;
    }
    location ~ ^/(app_dev|config)\.php(/|$) {
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        fastcgi_param DOCUMENT_ROOT $realpath_root;
    }
    location ~ ^/app\.php(/|$) {
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        fastcgi_param DOCUMENT_ROOT $realpath_root;
        internal;
    }
    location ~ \.php$ {
      return 404;
    }

    error_log /var/log/nginx/project_error.log;
    access_log /var/log/nginx/project_access.log;
}

the following hiera config is currently not working, i get a Duplicate declaration: Concat::Fragment[example.com-... error.
i also was forced to use the internal: true setting on loc1 because of the Cannot create a location reference without a www_root, proxy, location_alias, fastcgi, uwsgi, stub_status, internal, or location_custom_cfg defined error. i will post the working hiera file here in the comments as soon as i figured out (looks like i have to use location_custom_cfg).

profile::nginx::vhosts:
  'example.com':
    server_name: ['example.com','www.example.com']
    www_root: '/tmp'

profile::nginx::locations:
  loc1:
    vhost: 'example.com'
    location: '/'
    internal: true
    try_files: ['$uri', '/app.php$is_args$args']
  loc2:
    vhost: 'example.com'
    location: '~ ^/(app_dev|config)\.php(/|$)'
    fastcgi: unix:/run/php5-fpm-app.sock
    fastcgi_split_path: '^(.+\.php)(/.*)$'
    fastcgi_param:
      SCRIPT_FILENAME: $realpath_root$fastcgi_script_name
      DOCUMENT_ROOT: $realpath_root
@c33s
Copy link
Member Author

c33s commented Sep 6, 2016

as currently the following PR is open #834 the try_files part has to be done in a custom location

@wyardley
Copy link
Collaborator

wyardley commented Oct 8, 2016

As they say, PRs are gratefully accepted. 😉
I encountered a similar problem today, setting use_default_location: false resolved it for me. I opened #902 to track that specific issue. #544 also seems to be related.

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

2 participants