Forge Home

letsencrypt_nginx

Let's Encrypt Nginx

14,131 downloads

5,894 latest version

4.6 quality score

We run a couple of automated
scans to help you access a
module's quality. Each module is
given a score based on how well
the author has formatted their
code and documentation and
modules are also checked for
malware using VirusTotal.

Please note, the information below
is for guidance only and neither of
these methods should be considered
an endorsement by Puppet.

Support the Puppet Community by contributing to this module

You are welcome to contribute to this module by suggesting new features, currency updates, or fixes. Every contribution is valuable to help ensure that the module remains compatible with the latest Puppet versions and continues to meet community needs. Complete the following steps:

  1. Review the module’s contribution guidelines and any licenses. Ensure that your planned contribution aligns with the author’s standards and any legal requirements.
  2. Fork the repository on GitHub, make changes on a branch of your fork, and submit a pull request. The pull request must clearly document your proposed change.

For questions about updating the module, contact the module’s author.

Version information

  • 2.1.0 (latest)
  • 2.0.2
  • 2.0.1
  • 2.0.0 (deleted)
  • 1.2.1
  • 1.2.0
  • 1.1.3
  • 1.1.2
  • 1.1.1
released Aug 18th 2018
This version is compatible with:
  • ,

Start using this module

  • r10k or Code Manager
  • Bolt
  • Manual installation
  • Direct download

Add this module to your Puppetfile:

mod 'pgassmann-letsencrypt_nginx', '2.1.0'
Learn more about managing modules with a Puppetfile

Add this module to your Bolt project:

bolt module add pgassmann-letsencrypt_nginx
Learn more about using this module with an existing project

Manually install this module globally with Puppet module tool:

puppet module install pgassmann-letsencrypt_nginx --version 2.1.0

Direct download is not typically how you would use a Puppet module to manage your infrastructure, but you may want to download the module in order to inspect the code.

Download

Documentation

pgassmann/letsencrypt_nginx — version 2.1.0 Aug 18th 2018

Build Status

letsencrypt_nginx

Table of Contents

  1. Overview
  2. Module Description - What the module does and why it is useful
  3. Setup - The basics of getting started with letsencrypt_nginx
  4. Usage - Configuration options and additional functionality
  5. Reference - An under-the-hood peek at what the module is doing and how
  6. Limitations - OS compatibility, etc.
  7. Development - Guide for contributing to the module

Overview

The goal of Let's Encrypt is to automate ssl certificates.

This module is a helper to manage letsencrypt for puppet managed nginx servers.

Works with puppet/letsencrypt and puppet/nginx

Module Description

The goal of this module is to enable ssl on puppet managed nginx servers as simple as possible. The module reuses the domains configured in the server server_name

For the authorization, the webroot challenge is used and a custom location is automatically added to the ngninx server so that the challenge path is using the letsencrypt webroot. This allows to solve the challenge even if the server is just a proxy to another server.

Setup

What letsencrypt_nginx does

  • configure locations for the letsencrypt challenge path for defined servers and default server
  • Define default server for nginx that catches all requests that do not match a server_name
  • Uses letsencrypt::certonly to get certificate (requires puppet-letsencrypt)
  • Tell letsencrypt::certonly to manage cron for renewals

What letsencrypt_nginx does not

  • Manage nginx server ssl configuration. Configure the server ssl and certificate as seen in the examples below.

Setup Requirements

Requests to Port 80 (and 433) of the IPv4 address of the domains to encrypt need to reach your server.

This module uses the puppet/letsencrypt module, see it's documentation for the letsencrypt options

Usage

See the following example for encrypting a nginx server. This will successfully configure nginx, the server and the ssl certificat in one run, if added to a blank Server.

Important: You should declare letsencrypt_nginx resources after the nginx resources. The fetching of the configured domains is parse order dependent.

Let's encrypt nginx server

nginx::resource::server { 'letsencrypt-test1.example.com':
  server_name      => [
    'letsencrypt-test1.example.com',
    'letsencrypt-test2.example.com',
  ],
  proxy            => 'http://10.1.2.3',
  ssl              => true,
  ssl_redirect => true,
  ssl_key          => '/etc/letsencrypt/live/letsencrypt-test1.example.com/privkey.pem',
  ssl_cert         => '/etc/letsencrypt/live/letsencrypt-test1.example.com/fullchain.pem',
}
class { ::letsencrypt:
  email => 'foo@example.com',
}
class { 'letsencrypt_nginx':
  firstrun_webroot => '/usr/share/nginx/html',
  servers           => {
    'letsencrypt-test1.example.com' => {},
  },
}

To add ssl configuration to an existing installation, you need first to configure the locations for your default server and your existing server.

class { 'letsencrypt_nginx':
  locations => {
    'default' => {}
    'letsencrypt-test1.example.com' => {}
  }
}

If this is applied successfully, you can then add the ssl configuration to your nginx server as above and declare your letsencrypt_nginx::server

Hiera example

classes:
  - nginx
  - letsencrypt
  - letsencrypt_nginx

nginx::servers:
  'letsencrypt-test1.example.com':
      server_name:
                            - 'letsencrypt-test1.example.com'
                            - 'letsencrypt-test2.example.com'
      proxy:                'http://10.1.2.3'
      ssl:                  true
      ssl_redirect:     true
      ssl_key:              '/etc/letsencrypt/live/letsencrypt-test1.example.com/privkey.pem'
      ssl_cert:             '/etc/letsencrypt/live/letsencrypt-test1.example.com/fullchain.pem'

letsencrypt::email: 'foo@example.com'
# use staging server for testing
letsencrypt::config:
  server: 'https://acme-staging.api.letsencrypt.org/directory'

letsencrypt_nginx::firstrun_webroot: '/usr/share/nginx/html'
letsencrypt_nginx::servers:
  'letsencrypt-test1.example.com': {}

Reference

Class: letsencrypt_nginx

Let's Encrypt base configuration and hiera interface.

Parameters

  • default_server_name: name of nginx server that catches all requests that do not match any other server_name

  • webroot: This directory is configured as webroot for the webroot authentication locations added to the server to allow renewals

  • firstrun_webroot: Use different webroot on first run. Set this to the default webroot of the webserver if the service starts automatically when installed. E.g. For Nginx on Ubuntu: /usr/share/nginx/html

  • firstrun_standalone: Use standalone mode on first run. Set this to true if the webserver does not start automatically when installed. letsencrypt will use standalone mode to get the certificate before the webserver is started the first time.

  • locations, servers: These Parameters can be used to create instances of these defined types through hiera

Define: letsencrypt_nginx::server

Automatically get ssl certificate for nginx server

Parameters

  • domains: Array of domains to get ssl certificate for. If not defined, it uses the server_name array defined in the server. Use these domains instead of reading server_name array of server.

  • exclude_domains: Array of servernames that should not be added as alt names for the ssl cert. E.g. Elements of server_name that are defined in the server, but are not public resolvable or not valid fqdns.

  • webroot_paths: Passed to letsencrypt::certonly, not recommended to change An array of webroot paths for the domains in domains. Required if using plugin => 'webroot'. If domains and webroot_paths are not the same length, webroot_paths will cycle to make up the difference.

  • additional_args: Passed to letsencrypt::certonly An array of additional command line arguments to pass to the letsencrypt-auto command.

  • manage_cron: Passed to letsencrypt::certonly, default: true Boolean indicating whether or not to schedule cron job for renewal. Runs daily but only renews if near expiration, e.g. within 10 days.

Define: letsencrypt_nginx::location

Configure acme-challenge location webroot for a nginx server

Parameters

  • server: server to configure location for, defaults to $name

Development

Run bundle exec rake to execute the spec tests. There are already some basic tests for each class and define, but not all options are covered.

Release Notes

See CHANGELOG.md

Contributors

License

Apache 2.0

TODO & Ideas

  • Automatically configure SSL certificate and key on the server
  • Add Domains to existing Certificates
  • Support for RedHat, CentOS etc.