Defined Type: tlsproxy::localssl

Defined in:
modules/tlsproxy/manifests/localssl.pp

Overview

Parameters:

  • certs (Array) (defaults to: [])
  • certs_active (Array) (defaults to: [])
  • acme_subjects (Array) (defaults to: [])
  • acme_chief (Boolean) (defaults to: false)
  • acme_certname (String[1]) (defaults to: $title)
  • server_name (Stdlib::Host) (defaults to: $::fqdn)
  • server_aliases (Array[Stdlib::Host]) (defaults to: [])
  • default_server (Boolean) (defaults to: false)
  • upstream_ip (Stdlib::IP::Address) (defaults to: $::ipaddress)
  • upstream_ports (Array[Stdlib::Port]) (defaults to: [80])
  • tls_port (Stdlib::Port) (defaults to: 443)
  • redir_port (Optional[Stdlib::Port]) (defaults to: undef)
  • do_ocsp (Boolean) (defaults to: false)
  • skip_private (Boolean) (defaults to: false)
  • access_log (Boolean) (defaults to: false)
  • keepalive_timeout (Integer) (defaults to: 60)
  • keepalive_requests (Integer) (defaults to: 100)
  • read_timeout (Integer) (defaults to: 180)
  • ocsp_proxy (String) (defaults to: '')
  • only_get_requests (Boolean) (defaults to: false)
  • ssl_ecdhe_curve (Boolean) (defaults to: true)


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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
# File 'modules/tlsproxy/manifests/localssl.pp', line 92

define tlsproxy::localssl(
    Array                  $certs              = [],
    Array                  $certs_active       = [],
    Array                  $acme_subjects      = [],
    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                $do_ocsp            = false,
    Boolean                $skip_private       = false,
    Boolean                $access_log         = false,
    Integer                $keepalive_timeout  = 60,
    Integer                $keepalive_requests = 100,
    Integer                $read_timeout       = 180,
    String                 $ocsp_proxy         = '',
    Boolean                $only_get_requests  = false,
    Boolean                $ssl_ecdhe_curve    = true,
) {
    if (!empty($certs) and !empty($acme_subjects)) or ($acme_chief and !empty($acme_subjects)) or (empty($certs) and empty($acme_subjects) and !$acme_chief) {
        fail('Specify exactly one of certs (and optionally acme_chief) or acme_subjects')
    }

    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 = hiera('tlsproxy::localssl::proxy_request_buffering', '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 = hiera('tlsproxy::localssl::fastopen_pending_max', 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 !empty($certs) and !empty($certs_active) {
        # Ideally, we'd sanity-check that active is a subset of certs, too
        $certs_nginx = $certs_active
    } else {
        $certs_nginx = $certs
    }

    $certs.each |String $cert| {
        if !defined(Sslcert::Certificate[$cert]) {
            sslcert::certificate { $cert:
                skip_private => $skip_private,
                before       => Service['nginx'],
            }
        }
    }
    if !empty($acme_subjects) {
        if !defined(Letsencrypt::Cert::Integrated[$server_name]) {
            letsencrypt::cert::integrated { $server_name:
                subjects   => join($acme_subjects, ','),
                puppet_svc => 'nginx',
                system_svc => 'nginx',
            }
        }
        # TODO: Maybe add monitoring to this in role::cache::ssl::unified
    }

    if $do_ocsp {
        require tlsproxy::ocsp

        $certs.each |String $cert| {
            if !defined(Sslcert::Ocsp::Conf[$cert]) {
                sslcert::ocsp::conf { $cert:
                    proxy  => $ocsp_proxy,
                    before => [Service['nginx'], Exec['nginx-reload']],
                }
            }
        }
    }

    if $acme_chief {
        if !defined(Acme_chief::Cert[$acme_certname]) {
            acme_chief::cert { $acme_certname:
                before => Service['nginx']
            }
        }
        if $do_ocsp {
            File["/etc/acmecerts/${acme_certname}"] ~> 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')
    }
}