Skip to content

Commit

Permalink
(MODULES-2188) Add support for PassengerBaseURI in Apache
Browse files Browse the repository at this point in the history
This adds a varaible and template block for using PassengerBaseURI in the vhost
  • Loading branch information
aronymous committed Sep 12, 2015
1 parent 8ef4ee5 commit 9367580
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'.
Expand Down
16 changes: 16 additions & 0 deletions manifests/vhost.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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']) {
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions spec/defines/vhost_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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' => [
Expand Down
7 changes: 7 additions & 0 deletions templates/vhost/_passenger_base_uris.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<% if @passenger_base_uris -%>

## Enable passenger base uris
<% Array(@passenger_base_uris).each do |uri| -%>
PassengerBaseURI <%= uri %>
<% end -%>
<% end -%>
8 changes: 8 additions & 0 deletions tests/vhost.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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'],
}

0 comments on commit 9367580

Please sign in to comment.