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

Add http2 directive instead of listen option #1579

Merged
merged 2 commits into from
Nov 13, 2023
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
20 changes: 20 additions & 0 deletions spec/defines/resource_server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,26 @@
it { is_expected.to contain_concat__fragment("#{title}-ssl-header").without_content(%r{ ssl on;}) }
end

context 'http2 on with fact nginx_version=1.25.1' do
let(:facts) { facts.merge(nginx_version: '1.25.1') }
let :params do
default_params.merge(
http2: 'on',
ssl: true,
ssl_key: '/tmp/dummy.key',
ssl_cert: '/tmp/dummy.crt'
)
end

it { is_expected.to contain_concat__fragment("#{title}-ssl-header").with_content(%r{^\s+http2\s+on;}) }
end

context 'with fact nginx_version=1.25.1' do
let(:facts) { facts.merge(nginx_version: '1.25.1') }

it { is_expected.to contain_concat__fragment("#{title}-ssl-header").with_content(%r{^\s+http2\s+off;}) }
end

context 'with ssl cert and key definitions' do
let(:pre_condition) do
<<-PUPPET
Expand Down Expand Up @@ -1428,7 +1448,7 @@

# TODO: implement test after this can be tested
# msg = %r{nginx: ssl must be true if listen_port is the same as ssl_port}
it 'Testing for warnings not yet implemented in classes'

Check warning on line 1451 in spec/defines/resource_server_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

nginx::resource::server on virtuozzolinux-7-x86_64 with Facter 3.14.5 and Puppet 8.3.1 os-independent items attribute resources when listen_port == ssl_port but ssl = false Testing for warnings not yet implemented in classes Skipped: Not yet implemented

Check warning on line 1451 in spec/defines/resource_server_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

nginx::resource::server on almalinux-8-x86_64 with Facter 4.2.5 and Puppet 8.3.1 os-independent items attribute resources when listen_port == ssl_port but ssl = false Testing for warnings not yet implemented in classes Skipped: Not yet implemented

Check warning on line 1451 in spec/defines/resource_server_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

nginx::resource::server on almalinux-9-x86_64 with Facter 4.2.10 and Puppet 8.3.1 os-independent items attribute resources when listen_port == ssl_port but ssl = false Testing for warnings not yet implemented in classes Skipped: Not yet implemented

Check warning on line 1451 in spec/defines/resource_server_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

nginx::resource::server on archlinux-rolling-x86_64 with Facter 4.2.9 and Puppet 8.3.1 os-independent items attribute resources when listen_port == ssl_port but ssl = false Testing for warnings not yet implemented in classes Skipped: Not yet implemented

Check warning on line 1451 in spec/defines/resource_server_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

nginx::resource::server on centos-7-x86_64 with Facter 4.2.2 and Puppet 8.3.1 os-independent items attribute resources when listen_port == ssl_port but ssl = false Testing for warnings not yet implemented in classes Skipped: Not yet implemented

Check warning on line 1451 in spec/defines/resource_server_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

nginx::resource::server on centos-8-x86_64 with Facter 4.2.2 and Puppet 8.3.1 os-independent items attribute resources when listen_port == ssl_port but ssl = false Testing for warnings not yet implemented in classes Skipped: Not yet implemented

Check warning on line 1451 in spec/defines/resource_server_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

nginx::resource::server on centos-9-x86_64 with Facter 4.2.2 and Puppet 8.3.1 os-independent items attribute resources when listen_port == ssl_port but ssl = false Testing for warnings not yet implemented in classes Skipped: Not yet implemented

Check warning on line 1451 in spec/defines/resource_server_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

nginx::resource::server on debian-10-x86_64 with Facter 4.2.2 and Puppet 8.3.1 os-independent items attribute resources when listen_port == ssl_port but ssl = false Testing for warnings not yet implemented in classes Skipped: Not yet implemented

Check warning on line 1451 in spec/defines/resource_server_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

nginx::resource::server on debian-11-x86_64 with Facter 4.2.5 and Puppet 8.3.1 os-independent items attribute resources when listen_port == ssl_port but ssl = false Testing for warnings not yet implemented in classes Skipped: Not yet implemented

Check warning on line 1451 in spec/defines/resource_server_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

nginx::resource::server on redhat-7-x86_64 with Facter 4.2.13 and Puppet 8.3.1 os-independent items attribute resources when listen_port == ssl_port but ssl = false Testing for warnings not yet implemented in classes Skipped: Not yet implemented

Check warning on line 1451 in spec/defines/resource_server_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

nginx::resource::server on virtuozzolinux-7-x86_64 with Facter 3.14.5 and Puppet 7.27.0 os-independent items attribute resources when listen_port == ssl_port but ssl = false Testing for warnings not yet implemented in classes Skipped: Not yet implemented

Check warning on line 1451 in spec/defines/resource_server_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

nginx::resource::server on almalinux-8-x86_64 with Facter 4.2.5 and Puppet 7.27.0 os-independent items attribute resources when listen_port == ssl_port but ssl = false Testing for warnings not yet implemented in classes Skipped: Not yet implemented

Check warning on line 1451 in spec/defines/resource_server_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

nginx::resource::server on almalinux-9-x86_64 with Facter 4.2.10 and Puppet 7.27.0 os-independent items attribute resources when listen_port == ssl_port but ssl = false Testing for warnings not yet implemented in classes Skipped: Not yet implemented

Check warning on line 1451 in spec/defines/resource_server_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

nginx::resource::server on archlinux-rolling-x86_64 with Facter 4.2.9 and Puppet 7.27.0 os-independent items attribute resources when listen_port == ssl_port but ssl = false Testing for warnings not yet implemented in classes Skipped: Not yet implemented

Check warning on line 1451 in spec/defines/resource_server_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

nginx::resource::server on centos-7-x86_64 with Facter 4.2.2 and Puppet 7.27.0 os-independent items attribute resources when listen_port == ssl_port but ssl = false Testing for warnings not yet implemented in classes Skipped: Not yet implemented

Check warning on line 1451 in spec/defines/resource_server_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

nginx::resource::server on centos-8-x86_64 with Facter 4.2.2 and Puppet 7.27.0 os-independent items attribute resources when listen_port == ssl_port but ssl = false Testing for warnings not yet implemented in classes Skipped: Not yet implemented

Check warning on line 1451 in spec/defines/resource_server_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

nginx::resource::server on centos-9-x86_64 with Facter 4.2.2 and Puppet 7.27.0 os-independent items attribute resources when listen_port == ssl_port but ssl = false Testing for warnings not yet implemented in classes Skipped: Not yet implemented

Check warning on line 1451 in spec/defines/resource_server_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

nginx::resource::server on debian-10-x86_64 with Facter 4.2.2 and Puppet 7.27.0 os-independent items attribute resources when listen_port == ssl_port but ssl = false Testing for warnings not yet implemented in classes Skipped: Not yet implemented

Check warning on line 1451 in spec/defines/resource_server_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

nginx::resource::server on debian-11-x86_64 with Facter 4.2.5 and Puppet 7.27.0 os-independent items attribute resources when listen_port == ssl_port but ssl = false Testing for warnings not yet implemented in classes Skipped: Not yet implemented

Check warning on line 1451 in spec/defines/resource_server_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

nginx::resource::server on redhat-7-x86_64 with Facter 4.2.13 and Puppet 7.27.0 os-independent items attribute resources when listen_port == ssl_port but ssl = false Testing for warnings not yet implemented in classes Skipped: Not yet implemented
end

context 'when listen_port != ssl_port' do
Expand Down
8 changes: 4 additions & 4 deletions templates/server/server_ssl_header.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
server {
<%- if @listen_ip.is_a?(Array) then -%>
<%- @listen_ip.each do |ip| -%>
listen <%= ip %>:<%= @ssl_port %> <% if @ssl_listen_option %>ssl<% end %><% if @http2 == 'on' %> http2<% end %><% if @spdy == 'on' %> spdy<% end %><% if @listen_options %> <%= @listen_options %><% end %>;
listen <%= ip %>:<%= @ssl_port %> <% if @ssl_listen_option %>ssl<% end %><% if scope.call_function('versioncmp', [scope['nginx::nginx_version'], '1.25.1']) < 0 && @http2 == 'on' %> http2<% end %><% if @spdy == 'on' %> spdy<% end %><% if @listen_options %> <%= @listen_options %><% end %>;
<%- end -%>
<%- else -%>
listen <%= @listen_ip %>:<%= @ssl_port %> <% if @ssl_listen_option %>ssl<% end %><% if @http2 == 'on' %> http2<% end %><% if @spdy == 'on' %> spdy<% end %><% if @listen_options %> <%= @listen_options %><% end %>;
listen <%= @listen_ip %>:<%= @ssl_port %> <% if @ssl_listen_option %>ssl<% end %><% if scope.call_function('versioncmp', [scope['nginx::nginx_version'], '1.25.1']) < 0 && @http2 == 'on' %> http2<% end %><% if @spdy == 'on' %> spdy<% end %><% if @listen_options %> <%= @listen_options %><% end %>;
<%- end -%>
<%= scope.function_template(["nginx/server/server_ssl_ipv6_listen.erb"]) %>
<%- if @rewrite_www_to_non_www -%>
Expand Down Expand Up @@ -48,10 +48,10 @@ server {
server {
<%- if @listen_ip.is_a?(Array) then -%>
<%- @listen_ip.each do |ip| -%>
listen <%= ip %>:<%= @ssl_port %> <% if @ssl_listen_option %>ssl<% end %><% if @http2 == 'on' %> http2<% end %><% if @spdy == 'on' %> spdy<% end %><% if @listen_options %> <%= @listen_options %><% end %>;
listen <%= ip %>:<%= @ssl_port %> <% if @ssl_listen_option %>ssl<% end %><% if scope.call_function('versioncmp', [scope['nginx::nginx_version'], '1.25.1']) < 0 && @http2 == 'on' %> http2<% end %><% if @spdy == 'on' %> spdy<% end %><% if @listen_options %> <%= @listen_options %><% end %>;
<%- end -%>
<%- else -%>
listen <%= @listen_ip %>:<%= @ssl_port %> <% if @ssl_listen_option %>ssl<% end %><% if @http2 == 'on' %> http2<% end %><% if @spdy == 'on' %> spdy<% end %><% if @listen_options %> <%= @listen_options %><% end %>;
listen <%= @listen_ip %>:<%= @ssl_port %> <% if @ssl_listen_option %>ssl<% end %><% if scope.call_function('versioncmp', [scope['nginx::nginx_version'], '1.25.1']) < 0 && @http2 == 'on' %> http2<% end %><% if @spdy == 'on' %> spdy<% end %><% if @listen_options %> <%= @listen_options %><% end %>;
<%- end -%>
<%= scope.function_template(["nginx/server/server_ssl_ipv6_listen.erb"]) %>
<%- if @rewrite_www_to_non_www -%>
Expand Down
4 changes: 2 additions & 2 deletions templates/server/server_ssl_ipv6_listen.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<%- if @ipv6_enable -%>
<%- if @ipv6_listen_ip.is_a?(Array) then -%>
<%- @ipv6_listen_ip.each do |ipv6| -%>
listen [<%= ipv6 %>]:<%= @ssl_port %> ssl<% if @http2 == 'on' %> http2<% end %><% if @spdy == 'on' %> spdy<% end %><% if @ipv6_listen_options %> <%= @ipv6_listen_options %><% end %>;
listen [<%= ipv6 %>]:<%= @ssl_port %> ssl<% if scope.call_function('versioncmp', [scope['nginx::nginx_version'], '1.25.1']) < 0 && @http2 == 'on' %> http2<% end %><% if @spdy == 'on' %> spdy<% end %><% if @ipv6_listen_options %> <%= @ipv6_listen_options %><% end %>;
<%- end -%>
<%- else -%>
listen [<%= @ipv6_listen_ip %>]:<%= @ssl_port %> ssl<% if @http2 == 'on' %> http2<% end %><% if @spdy == 'on' %> spdy<% end %><% if @ipv6_listen_options %> <%= @ipv6_listen_options %><% end %>;
listen [<%= @ipv6_listen_ip %>]:<%= @ssl_port %> ssl<% if scope.call_function('versioncmp', [scope['nginx::nginx_version'], '1.25.1']) < 0 && @http2 == 'on' %> http2<% end %><% if @spdy == 'on' %> spdy<% end %><% if @ipv6_listen_options %> <%= @ipv6_listen_options %><% end %>;
<%- end -%>
<%- end -%>
3 changes: 3 additions & 0 deletions templates/server/server_ssl_settings.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<% if scope.call_function('versioncmp', [scope['nginx::nginx_version'], '1.15.0']) < 0 -%>
ssl on;
<% end -%>
<% if scope.call_function('versioncmp', [scope['nginx::nginx_version'], '1.25.1']) >= 0 && @http2 -%>
http2 <%= @http2 %>;
<% end -%>
<% if @ssl_cert_real -%>
<% @ssl_cert_real.each do | cert | -%>
ssl_certificate <%= cert %>;
Expand Down
Loading