Skip to content

Commit

Permalink
Allows sub-uri deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
ares committed Oct 30, 2014
1 parent 1b656a5 commit bcdd51a
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
12 changes: 10 additions & 2 deletions manifests/config/passenger.pp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@
validate_bool($prestart)

$docroot = "${app_root}/public"
$suburi_parts = split($foreman::foreman_url, '/')
$suburi_parts_count = size($suburi_parts) - 1
if $suburi_parts_count >= 3 {
$suburi_without_slash = join(values_at($suburi_parts, ["3-$suburi_parts_count"]), '/')
if $suburi_without_slash {
$suburi = "/$suburi_without_slash"
}
}

include ::apache
include ::apache::mod::headers
Expand Down Expand Up @@ -100,7 +108,7 @@
priority => '05',
options => ['SymLinksIfOwnerMatch'],
custom_fragment => template('foreman/apache-fragment.conf.erb', 'foreman/_assets.conf.erb',
'foreman/_virt_host_include.erb'),
'foreman/_virt_host_include.erb', 'foreman/_suburi.conf.erb'),
}

if $ssl {
Expand Down Expand Up @@ -131,7 +139,7 @@
ssl_options => '+StdEnvVars',
ssl_verify_depth => '3',
custom_fragment => template('foreman/apache-fragment.conf.erb', 'foreman/_assets.conf.erb',
'foreman/_ssl_virt_host_include.erb'),
'foreman/_ssl_virt_host_include.erb', 'foreman/_suburi.conf.erb'),
}
}
} else {
Expand Down
3 changes: 2 additions & 1 deletion templates/_assets.conf.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Static public dir serving
<% unless @suburi %>
<Directory <%= @docroot %>>

<IfVersion < 2.4>
Expand Down Expand Up @@ -42,4 +43,4 @@
</IfModule>

</Directory>

<% end %>
12 changes: 12 additions & 0 deletions templates/_suburi.conf.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<% if @suburi %>
SetEnv RAILS_RELATIVE_URL_ROOT <%= @suburi %>
Alias <%= @suburi -%> <%= @docroot %>
<Location <%= @suburi -%>>
PassengerBaseURI /
PassengerAppRoot <%= @app_root %>
</Location>

<Directory <%= @docroot -%>>
Options -MultiViews
</Directory>
<% end %>
2 changes: 2 additions & 0 deletions templates/apache-fragment.conf.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<% unless @suburi %>
PassengerAppRoot <%= @app_root %>
<% end %>
<% if @ruby and !@ruby.empty? -%>
PassengerRuby <%= @ruby %>
<% end -%>
Expand Down

0 comments on commit bcdd51a

Please sign in to comment.