Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refs #33956 - make it easier to toggle asset proxying #1085

Merged
merged 1 commit into from
Sep 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 12 additions & 2 deletions manifests/config/apache.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
17 changes: 17 additions & 0 deletions spec/classes/foreman_config_apache_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down