71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
|
# File 'modules/tlsproxy/manifests/localssl.pp', line 71
define tlsproxy::localssl(
Boolean $acme_chief = false,
String[1] $acme_certname = $title,
Stdlib::Host $server_name = $::fqdn,
Array[Stdlib::Host] $server_aliases = [],
Boolean $default_server = false,
Stdlib::IP::Address $upstream_ip = $::ipaddress,
Array[Stdlib::Port] $upstream_ports = [80],
Stdlib::Port $tls_port = 443,
Optional[Stdlib::Port] $redir_port = undef,
Boolean $skip_private = false,
Boolean $access_log = false,
Integer $keepalive_timeout = 60,
Integer $keepalive_requests = 100,
Integer $read_timeout = 180,
Boolean $only_get_requests = false,
Boolean $enable_http2 = false,
Hash[String[1], Stdlib::Unixpath] $cfssl_paths = {}
) {
if $cfssl_paths.empty and !acme_chief {
fail('Must provide exactly one of cfssl_paths or acme_chief')
}
if $redir_port != undef and $tls_port != 443 {
fail('http -> https redirect only works with default 443 HTTPS port.')
}
# TODO: move this define to the profile module too?
require ::profile::tlsproxy::instance
$nginx_proxy_request_buffering = lookup('tlsproxy::localssl::proxy_request_buffering', {'default_value' => 'on'})
# Maximum number of pending TCP Fast Open requests before falling back to
# regular 3WHS. https://tools.ietf.org/html/rfc7413#section-5.1
$fastopen_pending_max = lookup('tlsproxy::localssl::fastopen_pending_max', {'default_value' => 150})
# Ensure that exactly one definition exists with default_server = true
# for a given port. If multiple defines on the same port have default_server
# set to true this resource will conflict.
# we configure this resource as an exec which does nothing and should
# never trigger. We define the resource so it still allows us to catch multiple
# definitions of default_server but shouldn't show as a change in puppet reporting
if $default_server {
exec { "tlsproxy localssl default_server on port ${tls_port}":
command => '/bin/true',
onlyif => '/bin/false',
refreshonly => true,
}
}
if $acme_chief {
if !defined(Acme_chief::Cert[$acme_certname]) {
acme_chief::cert { $acme_certname:
puppet_svc => 'nginx',
}
}
}
unless $cfssl_paths.empty {
File[$cfssl_paths.values] ~> Exec['nginx-reload']
# the certificate renewal does not trigger any of the File
# resources to get refreshed, so ensure we pick up the new
# certs whenever the chain gets updated
$chain_path = $cfssl_paths['chain']
Exec["create chained cert ${chain_path}"] ~> Exec['nginx-reload']
}
# used in localssl.erb to template upstream definition name
$basename = regsubst($title, '[\W_]', '-', 'G')
nginx::site { $name:
require => Exec["tlsproxy localssl default_server on port ${tls_port}"], # Ensure a default_server has been defined
content => template('tlsproxy/localssl.erb')
}
}
|