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: Ie5f2669a8686a3546b652251881615e0e18bf433
This commit is contained in:
Takashi Kajinami 2022-07-01 11:37:02 +09:00
parent ff956c7a5b
commit 5d3e8252d6
3 changed files with 31 additions and 10 deletions

View File

@ -86,6 +86,14 @@
# { python-path => '/my/python/virtualenv' }
# Defaults to {}
#
# [*headers*]
# (optional) Headers for the vhost.
# Defaults to undef
#
# [*request_headers*]
# (optional) Modifies collected request headers in various ways.
# Defaults to undef
#
# == Dependencies
#
# requires Class['apache'] & Class['zaqar']
@ -117,6 +125,8 @@ class zaqar::wsgi::apache (
$access_log_format = false,
$error_log_file = undef,
$custom_wsgi_process_options = {},
$headers = undef,
$request_headers = undef,
) {
include zaqar::deps
@ -148,6 +158,8 @@ class zaqar::wsgi::apache (
wsgi_script_dir => $::zaqar::params::zaqar_wsgi_script_path,
wsgi_script_file => 'zaqar-server',
wsgi_script_source => $::zaqar::params::zaqar_wsgi_script_source,
headers => $headers,
request_headers => $request_headers,
vhost_custom_fragment => 'WSGICallableObject app',
access_log_file => $access_log_file,
access_log_format => $access_log_format,

View File

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

View File

@ -40,6 +40,8 @@ describe 'zaqar::wsgi::apache' do
:custom_wsgi_process_options => {
'python_path' => '/my/python/path',
},
:headers => ['set X-XSS-Protection "1; mode=block"'],
:request_headers => ['set Content-Type "application/json"'],
}
end
it { is_expected.to contain_class('zaqar::params') }
@ -59,12 +61,14 @@ describe 'zaqar::wsgi::apache' do
:wsgi_script_dir => platform_params[:wsgi_script_path],
:wsgi_script_file => 'zaqar-server',
:wsgi_script_source => platform_params[:wsgi_script_source],
: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"'],
:custom_wsgi_process_options => {
'python_path' => '/my/python/path',
},
:access_log_file => '/var/log/httpd/access_log',
:access_log_format => 'some format',
:error_log_file => '/var/log/httpd/error_log',
)}
end
end