From 9367580e2dc72df792fdafc48c5a9c94d7725a59 Mon Sep 17 00:00:00 2001 From: Aaron Russell Date: Fri, 3 Jul 2015 09:48:50 -0400 Subject: [PATCH] (MODULES-2188) Add support for PassengerBaseURI in Apache This adds a varaible and template block for using PassengerBaseURI in the vhost --- README.md | 4 ++++ manifests/vhost.pp | 16 ++++++++++++++++ spec/defines/vhost_spec.rb | 1 + templates/vhost/_passenger_base_uris.erb | 7 +++++++ tests/vhost.pp | 8 ++++++++ 5 files changed, 36 insertions(+) create mode 100644 templates/vhost/_passenger_base_uris.erb diff --git a/README.md b/README.md index 769b937b8..ff4ce0007 100644 --- a/README.md +++ b/README.md @@ -2114,6 +2114,10 @@ This directive is equivalent to proxy_pass, but takes regular expressions, see [ Specifies the resource identifiers for a rack configuration. The file paths specified are listed as rack application roots for [Phusion Passenger](http://www.modrails.com/documentation/Users%20guide%20Apache.html#_railsbaseuri_and_rackbaseuri) in the _rack.erb template. Defaults to 'undef'. +#####`passenger_base_uris` + +Used to specify that the given URI is a Phusion Passenger-served application. The file paths specified are listed as passenger application roots for [Phusion Passenger](https://www.phusionpassenger.com/documentation/Users%20guide%20Apache.html#PassengerBaseURI) in the _passenger_base_uris.erb template. Defaults to 'undef'. + ##### `redirect_dest` Specifies the address to redirect to. Defaults to 'undef'. diff --git a/manifests/vhost.pp b/manifests/vhost.pp index 20b1aa6b9..1c7224268 100644 --- a/manifests/vhost.pp +++ b/manifests/vhost.pp @@ -80,6 +80,7 @@ $redirectmatch_regexp = undef, $redirectmatch_dest = undef, $rack_base_uris = undef, + $passenger_base_uris = undef, $headers = undef, $request_headers = undef, $filters = undef, @@ -386,6 +387,11 @@ } } + # Load mod_passenger if needed and not yet loaded + if $passenger_base_uris { + include ::apache::mod::passenger + } + # Load mod_fastci if needed and not yet loaded if $fastcgi_server and $fastcgi_socket { if ! defined(Class['apache::mod::fastcgi']) { @@ -655,6 +661,16 @@ } } + # Template uses: + # - $passenger_base_uris + if $passenger_base_uris { + concat::fragment { "${name}-passenger_uris": + target => "${priority_real}${filename}.conf", + order => 155, + content => template('apache/vhost/_passenger_base_uris.erb'), + } + } + # Template uses: # - $redirect_source # - $redirect_dest diff --git a/spec/defines/vhost_spec.rb b/spec/defines/vhost_spec.rb index cb8c9e84b..82301c4ef 100644 --- a/spec/defines/vhost_spec.rb +++ b/spec/defines/vhost_spec.rb @@ -248,6 +248,7 @@ 'redirectmatch_regexp' => ['\.git$'], 'redirectmatch_dest' => ['http://www.example.com'], 'rack_base_uris' => ['/rackapp1'], + 'passenger_base_uris' => ['/passengerapp1'], 'headers' => 'Set X-Robots-Tag "noindex, noarchive, nosnippet"', 'request_headers' => ['append MirrorID "mirror 12"'], 'rewrites' => [ diff --git a/templates/vhost/_passenger_base_uris.erb b/templates/vhost/_passenger_base_uris.erb new file mode 100644 index 000000000..f3ef5aa0a --- /dev/null +++ b/templates/vhost/_passenger_base_uris.erb @@ -0,0 +1,7 @@ +<% if @passenger_base_uris -%> + + ## Enable passenger base uris +<% Array(@passenger_base_uris).each do |uri| -%> + PassengerBaseURI <%= uri %> +<% end -%> +<% end -%> diff --git a/tests/vhost.pp b/tests/vhost.pp index a46b67784..0cf8da75c 100644 --- a/tests/vhost.pp +++ b/tests/vhost.pp @@ -141,6 +141,7 @@ rack_base_uris => ['/rackapp1', '/rackapp2'], } + # Vhost to redirect non-ssl to ssl apache::vhost { 'sixteenth.example.com non-ssl': servername => 'sixteenth.example.com', @@ -251,3 +252,10 @@ access_log_env_var => 'admin', } +# Vhost with a passenger_base configuration +apache::vhost { 'twentysecond.example.com': + port => '80', + docroot => '/var/www/twentysecond', + rack_base_uris => ['/passengerapp1', '/passengerapp2'], +} +