Skip to content

docs: ssl.md - Revise letsencrypt section#2209

Merged
polarathene merged 9 commits intodocker-mailserver:masterfrom
polarathene:docs/revise-letsencrypt
Sep 26, 2021
Merged

docs: ssl.md - Revise letsencrypt section#2209
polarathene merged 9 commits intodocker-mailserver:masterfrom
polarathene:docs/revise-letsencrypt

Conversation

@polarathene
Copy link
Copy Markdown
Member

@polarathene polarathene commented Sep 24, 2021

Description

This is a follow-up to #2206

The Let's Encrypt section has been heavily revised. It includes the missing normalization for this section from the linked PR, and brings the section content up to date.

It is an initial pass and can probably be refined further. I've not yet fully verified the instructions work, only the nginx-proxy + acme-companion docker-compose example with staging certs works (however docker-mailserver isn't compatible with this as FQDN directory name is prefixed by _test_).

Link to the TLS docs preview page for this PR.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Improvement (non-breaking change that does improve existing functionality)

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (README.md or the documentation under docs/)
  • If necessary I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

- Added a warning to make users aware that using a public CA like _Let's Encrypt_ will publicly log information that may be somewhat sensitive, or undesirable to have historic records made public which cannot be redacted.
- The `letsencrypt` repo that was linked early in this guide now redirects to the [Certbot repo](https://github.com/certbot/certbot).

- More explicit volume mount instruction for CertBot; the local location was a tad vague.

- Better clarified `/etc/letsencrypt/live` contents structure, as well as FQDN info. Removed the misleading `fqdn:` from `docker-compose.yml` example snippet.
- General rewrite of the Docker Certbot section with additional tips (_renewals with automation, and using a alternative CA_).

- Generalized tone and paths in content.

- Update volume mount paths to be consistent with recent normalization effort.

- Moved some instructions into inline-comments for script examples instead.
- Break apart into individual steps, indenting content into the step as appropriate.

- Use normalized volume paths (`docker-data/<service>/` prefix).

- `letsencrypt-nginx-proxy-companion` has _changed project name to `acme-companion`_, and _transferred to new maintainers and the `nginx-proxy` organization_. This also affects the DockerHub image references.

- `acme-companion` has _switched from using `simp_le` to `acme.sh`_ for provisioning certificates. This requires mounting an additional volume for persisting provisioner state.

- The dummy container (_webmail_) is no longer `library/nginx`, just [`nginx`](https://hub.docker.com/_/nginx). This container also doesn't appear to be required. I've verified that the ENV can be given to the `mailserver` service container directly. Retained for now.
Heavy rewrite of this section. Like the previous commit mentions, this content was outdated. It has been simplified with improved documentation and reference links.

It also looks like there was a mistake in the existing config example as it uses the regular `nginx` image instead of `nginx-proxy`.

- The bulk of the `mailserver` service has been removed, users are advised to have an existing `docker-compose.yml` config for `docker-mailserver` and update only what is relevant to integrate with the cert provisioner.

- `DEBUG` is _false_ by default.

- The `networks:` portion of the example appears to be taken from upstream, _which that has since dropped it_. While we could continue to document this, I consider it more of an advanced config detail that we don't need to touch on in our docs.

- The `htpasswd` volume is unnecessary, only relevant if using _"Basic Authentication"_ to protect access to web service endpoints. `conf.d/` is also not required by default, it can be useful for the `standalone` mode (_documented as a `tip`_). Remaining volumes have inline-comments to document their purpose.

- `volumes_from:` is _not supported in v3 Compose format_, _only v2_ and the Docker CLI. I did not want to advise v2, so I've duplicated the volumes between the two containers instead. Internally `acme-companion` would rely on `volumes_from:` to identify the `nginx-proxy` container, it _provides alternative discovery methods_, the label is outdated and refers the legacy label (_their script logic is the same_); using the ENV `NGINX_PROXY_CONTAINER` seemed most appropriate and has been added.

- Upstream `acme-companion` docs only cover support for v2 Compose format. _There is a note regarding `nginx-proxy`_ having _volumes configured in it's Dockerfile_. Providing a volume for `/etc/nginx/dhparam` is required to avoid creating anonymous volumes each run of `nginx-proxy`. I've used a named data volume here to make it stick out more, it's not desirable and upstream should fix this, then we can drop it.

- I've also opted to only demonstrate the _Two Container (Basic) setup_ that upstream documents. Previously our docs have been showing _`docker-gen` with the Three Container (Advanced) setup_, which allows for not having the Docker API socket attached as a volume to a container exposed to the web. This reduces the security a bit, and I have not mentioned that on our docs. I could caution the reader with a link to upstream about the risk, but I don't think we should maintain the `docker-gen` setup.
@polarathene
Copy link
Copy Markdown
Member Author

polarathene commented Sep 24, 2021

The full PR diff isn't as pleasant due to some poor line matching in the diff algorithm? I've ensured each sub-section has it's own commit with related commit message if you'd find that easier to review with.

URLs are only in the overview notes below (since I've seen some weird stuff when referencing github content in commits that get forked/rebased or something by other users, triggering multiple references on an issue/PR/commit).

NOTE: On a Ubuntu 21.04 VPS instance, docker-compose is version 1.25 (from 2020), this fails to run docker-compose.yml examples versioned 3.8, requiring the version be dropped down to 3.7.

Commit Overview:

  • Added a warning to make users aware that using a public CA like Let's Encrypt will publicly log information that may be somewhat sensitive, or undesirable to have historic records made public which cannot be redacted.
  • The letsencrypt repo that was linked early in this guide now redirects to the Certbot repo.
  • More explicit volume mount instruction for CertBot; the local location was a tad vague.
  • Better clarified /etc/letsencrypt/live contents structure, as well as FQDN info. Removed the misleading fqdn: from docker-compose.yml example snippet.
  • General rewrite of the Certbot section with additional tips, and heavy rewrite of nginx-proxy sections.
  • Links extracted to the bottom of the file, and many new supporting links added.


Example - nginx-proxy + acme-companion with docker-compose.yml:

  • The bulk of the mailserver service has been removed, users are advised to have an existing docker-compose.yml config for docker-mailserver and update only what is relevant to integrate with the cert provisioner.
  • DEBUG is false by default.
  • The htpasswd volume is unnecessary, only relevant if using "Basic Authentication" to protect access to web service endpoints. conf.d/ is also not required by default, it can be useful for the standalone mode (documented as a tip). Remaining volumes have inline-comments to document their purpose.
  • The networks: portion of the example appears to be taken from upstream, which that has since dropped it. While we could continue to document this, I consider it more of an advanced config detail that we don't need to touch on in our docs.
  • volumes_from: is not supported in v3 Compose format, only v2 and the Docker CLI. I did not want to advise v2, so I've duplicated the volumes between the two containers instead. Internally acme-companion would rely on volumes_from: to identify the nginx-proxy container, it provides alternative discovery methods, the label is outdated and refers the legacy label (their script logic is the same); using the ENV NGINX_PROXY_CONTAINER seemed most appropriate and has been added.
  • Upstream acme-companion docs only cover support for v2 Compose format. There is a note regarding nginx-proxy having volumes configured in it's Dockerfile. Providing a volume for /etc/nginx/dhparam is required to avoid creating anonymous volumes each run of nginx-proxy. I've used a named data volume here to make it stick out more, it's not desirable and upstream should fix this, then we can drop it.
  • I considered disabling DH param generation, as upstream is pointlessly generating DH params regardless of needing them, they have not yet adopted standardized DHE groups. acme-companion differs slightly in generation (a bit more secure by not using -DSAPARAM), but lacks an ENV to disable generation. Neither should be a concern for us, but I might open a PR to both projects to address it.
  • I've also opted to only demonstrate the Two Container (Basic) setup that upstream documents. Previously our docs have been showing docker-gen with the Three Container (Advanced) setup, which allows for not having the Docker API socket attached as a volume to a container exposed to the web. This reduces the security a bit, and I have not mentioned that on our docs. I could caution the reader with a link to upstream about the risk, but I don't think we should maintain the docker-gen setup.
  • acme-companion does support restarting a container when certificates are provisioned/renewed, but I assume that's not something we want to encourage vs having supervisorctl internally restart services? I've mentioned it along with other config ENV in a tip admonition.

@casperklein
Copy link
Copy Markdown
Member

These links on the top do not work:

  • Using Traefik
  • Using self-signed certificates
  • Using your own certificates

@polarathene
Copy link
Copy Markdown
Member Author

These links on the top do not work

Good spotting! Thanks for that. I really need to get that link checking lint added to the CI 😅

These mismatched the current section headers they were meant to link to.
@github-actions
Copy link
Copy Markdown
Contributor

Documentation preview for this PR is ready! 🎉

Built with commit: 07124f2

@georglauterbach
Copy link
Copy Markdown
Member

Nice PR! Ready to be merged I think :)

@georglauterbach georglauterbach added area/documentation kind/improvement Improve an existing feature, configuration file or the documentation priority/low labels Sep 26, 2021
@georglauterbach georglauterbach added this to the v10.2.0 milestone Sep 26, 2021
@polarathene polarathene merged commit 4f91620 into docker-mailserver:master Sep 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/documentation kind/improvement Improve an existing feature, configuration file or the documentation priority/low

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants