From 7fef3b2f77178544efcebf99ec0eaa33c58d80e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20=C4=8Capek?= Date: Sun, 15 Nov 2015 23:51:45 +0100 Subject: [PATCH] vhost_nginx: add new define for redmine virtualhost in nginx web server --- manifests/vhost_nginx.pp | 52 +++++++++++++++++++++++++++ templates/nginx_redmine_site.conf.erb | 25 +++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 manifests/vhost_nginx.pp create mode 100644 templates/nginx_redmine_site.conf.erb diff --git a/manifests/vhost_nginx.pp b/manifests/vhost_nginx.pp new file mode 100644 index 0000000..cda349e --- /dev/null +++ b/manifests/vhost_nginx.pp @@ -0,0 +1,52 @@ +# == Define: redmine::vhost_nginx +# +# Generates a vhost for redmine in nginx web server configuration +# +# === Parameters +# +# [*port*] +# port where this vhost should listen +# [*priority*] +# priority of the site configuration file +# [*serveraliases*] +# list of aliases of the vhost +# [*root_dir*] +# root directory of the redmine installation +# [*max_attachment_size*] +# maximum size of the attachment +# +# === Examples +# +# redmine::vhost_nginx { 'redmine.example.net': +# root_dir => '/srv/www/redmine.example.net', +# } +# +# === Authors +# +# Braiins Systems s.r.o. +# +# === Copyright +# +# Copyright 2015 Braiins Systems s.r.o. +# +define redmine::vhost_nginx( + $port='80', + $priority='50', + $max_attachment_size='20M', + $serveraliases=[], + $root_dir, +) { + nginx::vhost { $title: + port => $port, + priority => $priority, + docroot => undef, + create_docroot => false, + template => 'redmine/nginx_redmine_site.conf.erb', + options => { + 'serveraliases' => $serveraliases, + 'upstream_web' => "upstream-web-puma-redmine-${title}", + 'upstream_socket_path' => "${root_dir}/current/tmp/sockets/puma.socket", + 'client_max_body_size' => $max_attachment_size, + } + } +} diff --git a/templates/nginx_redmine_site.conf.erb b/templates/nginx_redmine_site.conf.erb new file mode 100644 index 0000000..da3ad49 --- /dev/null +++ b/templates/nginx_redmine_site.conf.erb @@ -0,0 +1,25 @@ +# Virtual host <%= @name %> +# This file has been provided by puppet for <%= @fqdn %>. +# DON'T EDIT it manually, any changes will be lost +# + +upstream <%= @options['upstream_web'] %> { + server unix:<%= @options['upstream_socket_path'] %>; +} + +server { + listen <%= @port %>; + server_name <%= @name %> <%= @options['serveraliases'].join(" ") %>; + + access_log <%= scope.lookupvar('nginx::log_dir')%>/<%= @title %>.access.log; + error_log <%= scope.lookupvar('nginx::log_dir')%>/<%= @title %>.error.log; + + location / { + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_pass http://<%= @options['upstream_web'] %>; + client_max_body_size <%= @options['client_max_body_size'] %>; + client_body_buffer_size 128k; + } +}