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

dont deploy "ssl on" on nginx 1.15 or newer (for mailhost) #1281

Merged
merged 2 commits into from
Feb 9, 2019
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
1 change: 1 addition & 0 deletions spec/acceptance/nginx_mail_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class { 'nginx':
describe file('/etc/nginx/conf.mail.d/domain1.example.conf') do
it { is_expected.to be_file }
it { is_expected.to contain 'auth_http localhost/cgi-bin/auth;' }
it { is_expected.to contain 'listen *:465 ssl;' }
end

describe port(587) do
Expand Down
2 changes: 1 addition & 1 deletion spec/defines/resource_mailhost_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@
title: 'should set the IPv4 SSL listen port',
attr: 'ssl_port',
value: 45,
match: ' listen *:45;'
match: ' listen *:45 ssl;'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By default, ssl should not have appeared as the nginx_version fact isn't being set and add_listen_directive is therefore true.

},
{
title: 'should enable IPv6',
Expand Down
2 changes: 2 additions & 0 deletions templates/mailhost/mailhost.erb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ server {
<%- end -%>
<%= scope.function_template(["nginx/mailhost/mailhost_common.erb"]) -%>

<% if @add_listen_directive -%>
ssl off;
<% end -%>
starttls <%= @starttls %>;

<% if @starttls == 'on' || @starttls == 'only' %>
Expand Down
6 changes: 4 additions & 2 deletions templates/mailhost/mailhost_ssl.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ server {
<% end -%>
<%- if @listen_ip.is_a?(Array) then -%>
<%- @listen_ip.each do |ip| -%>
listen <%= ip %>:<%= @ssl_port %>;
listen <%= ip %>:<%= @ssl_port %><% unless @add_listen_directive -%> ssl<% end -%>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is broken I think (will be fixed as part of #1330).
The problem is @add_listen_directive is not in scope. Since it's always nil and nil is falsey, ssl is always added to the line.

<%- end -%>
<%- else -%>
listen <%= @listen_ip %>:<%= @ssl_port %>;
listen <%= @listen_ip %>:<%= @ssl_port %><% unless @add_listen_directive -%> ssl<% end -%>;
<%- end -%>
<%# check to see if ipv6 support exists in the kernel before applying -%>
<%# FIXME this logic is duplicated all over the place -%>
Expand All @@ -38,7 +38,9 @@ server {
<%- end -%>
<%= scope.function_template(["nginx/mailhost/mailhost_common.erb"]) -%>

<% if @add_listen_directive -%>
ssl on;
<% end -%>
starttls off;

<%= scope.function_template(["nginx/mailhost/mailhost_ssl_settings.erb"]) -%>
Expand Down