Skip to content

Instantly share code, notes, and snippets.

@Tombar
Created November 21, 2014 13:34
Show Gist options
  • Save Tombar/b84703af1b43b01c6c6f to your computer and use it in GitHub Desktop.
Save Tombar/b84703af1b43b01c6c6f to your computer and use it in GitHub Desktop.
hiera resources
I want to use a YAML/Hiera definition of resources as a `template` to create multiple instances of it
For example, having an nginx conf for drupal like below, I would like to create multiple sites using it
I understand i need to paremetrize some stuff also.
Is it possible?
---
### SAMPLE NGINX VHOST CONFIG FOR DRUPAL
nginx::nginx_vhosts:
'drupal':
access_log: /var/log/nginx/drupal7.access.log
error_log: /var/log/nginx/drupal7.error.log
www_root: /var/www/drupal
location_cfg_prepend:
- try_files $uri $uri/ @rewrite
nginx::nginx_locations:
# This matters if you use drush because drush copies backups of modules
# to this directory. In the event personal information wound up in the
# module, you want to know outside users can't access it.
backup:
vhost: drupal
www_root: /fake
location: '= /backup'
location_cfg_prepend:
- deny all
# Very rarely should these ever be accessed outside of your lan
misc:
vhost: drupal
www_root: /fake
location: '~* \.(txt|log)$'
location_cfg_prepend:
- deny all
# This location block protects against a known attack. It happens if
# the attacker uploads a non-php file and attempts to run it as a
# php file on the server.
security1:
vhost: drupal
www_root: /fake
location: '~ \..*/.*\.php$'
location_cfg_prepend:
- return 403
# This will rewrite our request from domain.com/node/1/ to domain.com/index.php?q=node/1
# This could be done in try_files without a rewrite however, the GlobalRedirect
# module enforces no slash (/) at the end of URL's. This rewrite removes that
# so no infinite redirect loop is reached.
rewrite:
vhost: drupal
www_root: /fake
location: '@rewrite'
location_cfg_prepend:
- rewrite ^/(.*)$ /index.php?q=$1
# If a PHP file is served, this block will handle the request. This block
# works on the assumption you are using php-cgi listening on /tmp/phpcgi.socket.
# Please see the php example (usr/share/doc/nginx/exmaples/php) for more
# information about setting up PHP.
# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
php:
vhost: drupal
www_root: /var/www/drupal
location: '~ \.php$'
fastcgi: 'drupal_php_nodes'
location_cfg_prepend:
- include /etc/nginx/fastcgi_params
- add_header X-Node $upstream_addr
- fastcgi_split_path_info ^(.+\.php)(/.+)$
- fastcgi_intercept_errors on
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment