diff --git a/README.md b/README.md index 704d3e14f..eb08ea222 100644 --- a/README.md +++ b/README.md @@ -82,8 +82,8 @@ This module configures Apache to serve static assets from SELinux policy, like the one introduced in [`foreman-selinux` version 3.5](https://projects.theforeman.org/issues/35402). Additionally, some plugin packages might be incomplatible with such -a deployment. To use the old style, set -`foreman::config::apache::proxy_no_proxy_uris` to not include `/assets`. +a deployment. To serve assets via Rails again, set +`foreman::config::apache::proxy_assets` to `true`. ## Types and providers diff --git a/manifests/config/apache.pp b/manifests/config/apache.pp index 68795c4a7..9981bec85 100644 --- a/manifests/config/apache.pp +++ b/manifests/config/apache.pp @@ -58,6 +58,9 @@ # @param proxy_no_proxy_uris # URIs not to proxy # +# @param proxy_assets +# Whether assets paths (/assets, /webpack) should be proxied or not. +# # @param foreman_url # The URL Foreman should be reachable under. Used for loading the application # on startup rather than on demand. @@ -96,7 +99,8 @@ Pattern['^(https?|unix)://'] $proxy_backend = 'unix:///run/foreman.sock', Boolean $proxy_add_headers = true, Hash $proxy_params = { 'retry' => '0' }, - Array[String] $proxy_no_proxy_uris = ['/pulp', '/pub', '/icons', '/server-status', '/webpack', '/assets'], + Array[String] $proxy_no_proxy_uris = ['/pulp', '/pub', '/icons', '/server-status'], + Boolean $proxy_assets = false, Boolean $ssl = false, Optional[Stdlib::Absolutepath] $ssl_ca = undef, Optional[Stdlib::Absolutepath] $ssl_chain = undef, @@ -174,12 +178,18 @@ "unset ${header}" } + if $proxy_assets { + $_proxy_no_proxy_uris = $proxy_no_proxy_uris + } else { + $_proxy_no_proxy_uris = $proxy_no_proxy_uris + ['/webpack', '/assets'] + } + $vhost_http_internal_options = { 'proxy_preserve_host' => true, 'proxy_add_headers' => $proxy_add_headers, 'request_headers' => $vhost_http_request_headers, 'proxy_pass' => { - 'no_proxy_uris' => $proxy_no_proxy_uris, + 'no_proxy_uris' => $_proxy_no_proxy_uris, 'path' => pick($suburi, '/'), 'url' => $_proxy_backend, 'params' => $proxy_params, diff --git a/spec/classes/foreman_config_apache_spec.rb b/spec/classes/foreman_config_apache_spec.rb index 603a6d94b..b32793cfc 100644 --- a/spec/classes/foreman_config_apache_spec.rb +++ b/spec/classes/foreman_config_apache_spec.rb @@ -105,6 +105,23 @@ } end + describe 'with asset proxying enabled' do + let(:params) do + super().merge( + proxy_assets: true + ) + end + + it { should contain_apache__vhost('foreman') + .with_proxy_pass( + "no_proxy_uris" => ['/pulp', '/pub', '/icons', '/server-status'], + "path" => '/', + "url" => 'unix:///run/foreman.sock|http://foreman/', + "params" => { "retry" => '0' }, + ) + } + end + describe 'with ssl' do let(:params) do {