Skip to content

Commit 6ef5fbf

Browse files
Merge pull request #2393 from ekohl/mod_proxy_http2
Add mod_proxy_http2 support
2 parents 1f0f3e1 + 1769dbd commit 6ef5fbf

File tree

6 files changed

+127
-1
lines changed

6 files changed

+127
-1
lines changed

manifests/mod/proxy_http2.pp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# @summary
2+
# Installs `mod_proxy_http2`.
3+
#
4+
# @see https://httpd.apache.org/docs/current/mod/mod_proxy_http2.html for additional documentation.
5+
#
6+
class apache::mod::proxy_http2 {
7+
require apache::mod::proxy
8+
apache::mod { 'proxy_http2': }
9+
}

manifests/vhost.pp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2303,6 +2303,21 @@
23032303

23042304
if $directory['provider'] and $directory['provider'] =~ 'location' and ('proxy_pass' in $directory or 'proxy_pass_match' in $directory) {
23052305
include apache::mod::proxy_http
2306+
2307+
# To match processing in templates/vhost/_directories.erb
2308+
if $directory['proxy_pass_match'] {
2309+
Array($directory['proxy_pass_match']).each |$proxy| {
2310+
if $proxy['url'] =~ /"h2c?:\/\// {
2311+
include apache::mod::proxy_http2
2312+
}
2313+
}
2314+
} elsif $directory['proxy_pass'] {
2315+
Array($directory['proxy_pass']).each |$proxy| {
2316+
if $proxy['url'] =~ /"h2c?:\/\// {
2317+
include apache::mod::proxy_http2
2318+
}
2319+
}
2320+
}
23062321
}
23072322

23082323
if 'request_headers' in $directory {
@@ -2453,6 +2468,16 @@
24532468
if ($proxy_dest or $proxy_pass or $proxy_pass_match or $proxy_dest_match or $proxy_preserve_host or ($proxy_add_headers =~ NotUndef)) and $ensure == 'present' {
24542469
include apache::mod::proxy_http
24552470

2471+
# To match processing in templates/vhost/_proxy.erb
2472+
if $proxy_dest =~ Pattern[/^h2c?:\/\//] or $proxy_dest_match =~ Pattern[/^h2c?:\/\//] {
2473+
include apache::mod::proxy_http2
2474+
}
2475+
[$proxy_pass, $proxy_pass_match].flatten.each |$proxy| {
2476+
if $proxy and $proxy['url'] =~ Pattern[/^h2c?:\/\//] {
2477+
include apache::mod::proxy_http2
2478+
}
2479+
}
2480+
24562481
concat::fragment { "${name}-proxy":
24572482
target => "${priority_real}${filename}.conf",
24582483
order => 170,

manifests/vhost/proxy.pp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,16 @@
124124
include apache::mod::proxy
125125
include apache::mod::proxy_http
126126

127+
# To match processing in templates/vhost/_proxy.erb
128+
if $proxy_dest =~ Pattern[/^h2c?:\/\//] or $proxy_dest_match =~ Pattern[/^h2c?:\/\//] {
129+
include apache::mod::proxy_http2
130+
}
131+
[$proxy_pass, $proxy_pass_match].flatten.each |$proxy| {
132+
if $proxy and $proxy['url'] =~ Pattern[/^h2c?:\/\//] {
133+
include apache::mod::proxy_http2
134+
}
135+
}
136+
127137
unless $proxy_dest or $proxy_pass or $proxy_pass_match or $proxy_dest_match {
128138
fail('At least one of proxy_dest, proxy_pass, proxy_pass_match or proxy_dest_match must be given')
129139
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# frozen_string_literal: true
2+
3+
require 'spec_helper'
4+
5+
describe 'apache::mod::proxy_http2' do
6+
on_supported_os.each do |os, os_facts|
7+
context "on #{os}" do
8+
let(:facts) { os_facts }
9+
10+
it { is_expected.to compile.with_all_deps }
11+
it { is_expected.to contain_class('apache::mod::proxy') }
12+
it { is_expected.to contain_apache__mod('proxy_http2') }
13+
end
14+
end
15+
end
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# frozen_string_literal: true
2+
3+
require 'spec_helper'
4+
5+
describe 'apache::mod::proxy_http' do
6+
on_supported_os.each do |os, os_facts|
7+
context "on #{os}" do
8+
let(:facts) { os_facts }
9+
10+
it { is_expected.to compile.with_all_deps }
11+
it { is_expected.to contain_class('apache::mod::proxy') }
12+
it { is_expected.to contain_apache__mod('proxy_http') }
13+
end
14+
end
15+
end

spec/defines/vhost_proxy_spec.rb

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
it { is_expected.to compile.and_raise_error(%r{At least one of}) }
2424
end
2525

26-
context 'with proxy_dest' do
26+
context 'with proxy_pass' do
2727
let(:params) do
2828
super().merge(
2929
proxy_pass: [
@@ -37,6 +37,8 @@
3737

3838
it 'creates a concat fragment' do
3939
expect(subject).to compile.with_all_deps
40+
expect(subject).to contain_class('apache::mod::proxy')
41+
expect(subject).to contain_class('apache::mod::proxy_http')
4042
expect(subject).to contain_concat('15-default-80.conf')
4143
expect(subject).to create_concat__fragment('default-myproxy-proxy')
4244
.with_target('15-default-80.conf')
@@ -51,6 +53,56 @@
5153
CONTENT
5254
)
5355
end
56+
57+
context 'with HTTP/2 proxy_dest URL' do
58+
let(:params) do
59+
super().merge(proxy_dest: 'h2://localhost:8080/')
60+
end
61+
62+
it { is_expected.to compile.with_all_deps }
63+
it { is_expected.to contain_class('apache::mod::proxy_http2') }
64+
end
65+
66+
context 'with HTTP/2 proxy_dest_match URL' do
67+
let(:params) do
68+
super().merge(proxy_dest_match: 'h2://localhost:8080/')
69+
end
70+
71+
it { is_expected.to compile.with_all_deps }
72+
it { is_expected.to contain_class('apache::mod::proxy_http2') }
73+
end
74+
75+
context 'with HTTP/2 proxy_pass URL' do
76+
let(:params) do
77+
super().merge(
78+
proxy_pass: [
79+
{
80+
path: '/',
81+
url: 'h2://localhost:8080/'
82+
},
83+
],
84+
)
85+
end
86+
87+
it { is_expected.to compile.with_all_deps }
88+
it { is_expected.to contain_class('apache::mod::proxy_http2') }
89+
end
90+
91+
context 'with HTTP/2 proxy_pass_match URL' do
92+
let(:params) do
93+
super().merge(
94+
proxy_pass_match: [
95+
{
96+
path: '/',
97+
url: 'h2://localhost:8080/'
98+
},
99+
],
100+
)
101+
end
102+
103+
it { is_expected.to compile.with_all_deps }
104+
it { is_expected.to contain_class('apache::mod::proxy_http2') }
105+
end
54106
end
55107
end
56108
end

0 commit comments

Comments
 (0)