Expose headers option of apache::vhost

The headers option in apache::vhost is required in some case, for
example when adding the X-XSS-Protection header. This change allows
customizing the option for the api vhost.

This change also adds support for request_headers so that both request
headers and response headers can customized.

Change-Id: I8500d2de47c4f50920336741db5840bc44faca8b
This commit is contained in:
Takashi Kajinami 2022-07-01 10:37:48 +09:00
parent 486b37d6f5
commit 029c455e4c
3 changed files with 23 additions and 0 deletions

View File

@ -80,6 +80,14 @@
# (Optional) The error log file name for the virtualhost.
# Defaults to undef
#
# [*headers*]
# (optional) Headers for the vhost.
# Defaults to undef
#
# [*request_headers*]
# (optional) Modifies collected request headers in various ways.
# Defaults to undef
#
# [*vhost_custom_fragment*]
# (optional) Passes a string of custom configuration
# directives to be placed at the end of the vhost configuration.
@ -111,6 +119,8 @@ class placement::wsgi::apache (
$access_log_file = false,
$access_log_format = false,
$error_log_file = undef,
$headers = undef,
$request_headers = undef,
$vhost_custom_fragment = undef,
) {
@ -144,6 +154,8 @@ class placement::wsgi::apache (
wsgi_script_dir => $::placement::params::wsgi_script_path,
wsgi_script_file => 'placement-api',
wsgi_script_source => $::placement::params::wsgi_script_source,
headers => $headers,
request_headers => $request_headers,
access_log_file => $access_log_file,
access_log_format => $access_log_format,
error_log_file => $error_log_file,

View File

@ -0,0 +1,5 @@
---
features:
- |
The ``placement::wsgi::apache`` class now supports customizing
request/response headers added by apache.

View File

@ -28,6 +28,8 @@ describe 'placement::wsgi::apache' do
:wsgi_script_dir => platform_params[:wsgi_script_path],
:wsgi_script_file => 'placement-api',
:wsgi_script_source => platform_params[:wsgi_script_source],
:headers => nil,
:request_headers => nil,
:access_log_file => false,
:access_log_format => false,
:error_log_file => nil,
@ -57,6 +59,8 @@ describe 'placement::wsgi::apache' do
:access_log_file => '/var/log/httpd/access_log',
:access_log_format => 'some format',
:error_log_file => '/var/log/httpd/error_log',
:headers => ['set X-XSS-Protection "1; mode=block"'],
:request_headers => ['set Content-Type "application/json"'],
}
end
@ -87,6 +91,8 @@ describe 'placement::wsgi::apache' do
:wsgi_script_dir => platform_params[:wsgi_script_path],
:wsgi_script_file => 'placement-api',
:wsgi_script_source => platform_params[:wsgi_script_source],
:headers => ['set X-XSS-Protection "1; mode=block"'],
:request_headers => ['set Content-Type "application/json"'],
:access_log_file => params[:access_log_file],
:access_log_format => params[:access_log_format],
:error_log_file => params[:error_log_file],