Skip to content

Commit

Permalink
vhost_nginx: add new define for redmine virtualhost in nginx web server
Browse files Browse the repository at this point in the history
  • Loading branch information
janbraiins committed Nov 18, 2015
1 parent 06f30a2 commit 7fef3b2
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 0 deletions.
52 changes: 52 additions & 0 deletions manifests/vhost_nginx.pp
Original file line number Diff line number Diff line change
@@ -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,
}
}
}
25 changes: 25 additions & 0 deletions templates/nginx_redmine_site.conf.erb
Original file line number Diff line number Diff line change
@@ -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;
}
}

0 comments on commit 7fef3b2

Please sign in to comment.