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: Ia75fb9a1b343293c2b962ae4f90894e094149acc
This commit is contained in:
Takashi Kajinami 2022-07-01 10:07:29 +09:00
parent 7685156256
commit d7dc6e1a4f
3 changed files with 23 additions and 2 deletions

View File

@ -95,6 +95,14 @@
# (Optional) The location of the octavia WSGI script.
# Defaults to $::octavia::params::octavia_wsgi_script_source
#
# [*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.
@ -128,6 +136,8 @@ class octavia::wsgi::apache (
$custom_wsgi_process_options = {},
$wsgi_script_dir = $::octavia::params::octavia_wsgi_script_path,
$wsgi_script_source = $::octavia::params::octavia_wsgi_script_source,
$headers = undef,
$request_headers = undef,
$vhost_custom_fragment = undef,
) inherits octavia::params {
@ -160,9 +170,11 @@ class octavia::wsgi::apache (
wsgi_script_dir => $wsgi_script_dir,
wsgi_script_file => 'app',
wsgi_script_source => $wsgi_script_source,
headers => $headers,
request_headers => $request_headers,
custom_wsgi_process_options => $custom_wsgi_process_options,
access_log_file => $access_log_file,
access_log_format => $access_log_format,
error_log_file => $error_log_file,
custom_wsgi_process_options => $custom_wsgi_process_options,
}
}

View File

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

View File

@ -25,7 +25,7 @@ describe 'octavia::wsgi::apache' do
)}
end
context 'when overriding parameters using different ports' do
context 'when overriding parameters' do
let :params do
{
:servername => 'dummy.host',
@ -42,6 +42,8 @@ describe 'octavia::wsgi::apache' do
:error_log_file => '/var/log/httpd/error_log',
:wsgi_script_dir => '/var/lib/openstack/cgi-bin/octavia',
:wsgi_script_source => '/my/path/app.wsgi',
:headers => ['set X-XSS-Protection "1; mode=block"'],
:request_headers => ['set Content-Type "application/json"'],
:vhost_custom_fragment => 'Timeout 99'
}
end
@ -63,6 +65,8 @@ describe 'octavia::wsgi::apache' do
:wsgi_script_dir => '/var/lib/openstack/cgi-bin/octavia',
:wsgi_script_file => 'app',
:wsgi_script_source => '/my/path/app.wsgi',
:headers => ['set X-XSS-Protection "1; mode=block"'],
:request_headers => ['set Content-Type "application/json"'],
:custom_wsgi_process_options => {
'python_path' => '/my/python/path',
},