Letsencrypt traefik v2 acme json#1553
Conversation
Will extract certificates from acme.json as written by traefik for usage in dovecot and postfix. Also watches acme.json for changes. For this to work the file has to be mounted/present at `/etc/letsencrypt/acme.json`
|
Thanks for the PR. Many of the changes seem to be indentation fixes, which is not ideal, but never mind. First question is if this is compatible with non-letsencrypt setups? I think it should be (the file is ignored if missing), am I right? Second question is traefik. I'm not sure how common it is to use traefik for letsencrypt in this community? Most issues I've seen mention caddy. It would have been nice to have a solution not tied to traefik (though of course supporting one product is better than supporting none...). Is the traefik format supported by other tools, for example caddy? |
|
indentation fixes: yes, you are right. Not ideal, but also not easy to keep the files clean. I had to laugh when reading this comment from almost 1 year ago:
|
|
It would be nice to use a different variable than
And is not compatible with traefik v1. |
|
Yes, this is traefik v2 (updated the PR-name). I'll update the PR to support something like If the acme.json is not in v2-format, it will not find any matching domain and will not extract any certificate |
|
Since I don't use {
"le": {
"Account": {},
"Certificates": [
{
"domain": {
"main": "*.example.com",
"sans": []
},
"certificate": "X",
"key": "Y",
"Store": "default"
}
]
}
}
|
/etc/letsencrypt/live/$HOSTNAME/key.pem and /etc/letsencrypt/live/$HOSTNAME/fullchain.pem are watched and will trigger a reload if changed
|
I'm not using {
"le": {
"Account": {},
"Certificates": [
{
"domain": {
"main": "example.com",
"sans": ["example.com", "*.example.com"]
},
"certificate": "X",
"key": "Y",
"Store": "default"
}
]
}
} |
set SSL_DOMAIN=*.example.com to extract a wildcard certificate from traefiks acme.json store
|
again an unrelated test failure as in #1560 |
|
Indeed, it is irritating. Just do a nonsense change (or force push with no change?) to trigger a rebuild. I used to be able to trigger that manually, but I can't. However, there are several changes in this PR that I don't understand:
Why have you changed that? |
|
Oh I'm sorry thanks for your careful observation. |
|
That's better. Unfortunately that stupid test that keeps failing is at it again. You have unusually bad luck, it normally happens less than one build in ten. Can you push a gain to trigger a rebuild, please? We really have to fix that, no time though. The problem with working for free :-). |
|
now it's green @erik-wramner |
|
Nice work. @MichaelSp will you update the Wiki with instructions on how to use traefik with docker-mailserver? Or do i misinterprete the current information in the wiki about traefik? |
|
@wernerfred thanks for the heads up. I've just updated the wiki: https://github.com/tomav/docker-mailserver/wiki/Configure-SSL#traefik |
|
I have a suggestion regarding this, isn't it better to make the extracted cert and key files part of the container itself, and not in the mounted volume?
Or maybe this whole logic should be provided as a separate container, as these extracted files are relevant not only to the mailserver, but potentially to other containers. What do you think? |
|
Functionality somewhat broken currently anyways: See #2239 |
It could probably be extracted to the same location as I'd like to refactor the related code, just pressed for time to spare and prioritize. |
|
@polarathene, So the workflow should look like this:
Is that correct? Could your refacoting consider that please when you have time? |
Please explain this scenario.
I'm not entirely familiar with the other two, but I think
Are you asking to use Traefik with |
|
@polarathene if I understand correctly, you think that Docker mailserver uses the acme.json directly? No, it doesn't, Docker mailserver extracts the .crt and .key files to be used by Dovecot and Postfix. And extracting the certificates directly inside the same folder where the acme.json lives is not good, this is exactly my point, because you may have the acme.json stored in a Docker named volume, and named volumes can be mounted only as whole (namely as folder), not using single files. And in case of acme.json, it is highly recommended to mount its named volume in read only mode, but this read-only mode will prohibit the .crt and .key files from being generated (or extracted) by the script, because the extraction will fail bacause of lack of permissions in that folder. Hopefully I could explain it. Please let me know if I misunderstood or missed anything. |
We can allow a variable to be passed in to override the location of the acme.json. Would that work for you? I have a PR open for some changes of this code and could include it. |
|
Hi @NorseGaud, it is actually about overriding the location of the extracted (generated) .crt and .key. Would that be possible? To best honest, I am still thinking about it, and I am not sure if this extraction should happen inside Docker mailserver at all. Actually IMO the correct workflow should be that Docker mailserver watches not acme.json, but .key and .crt, because these are the files that are interesting for Docker mailserver. So in simple words, the ideal solution should be actually to be able to monitor the .key and .crt files, without caring where they come from. The container should not care about acme.json. Even if it knows and includes some extraction logic, this should be optional in case someone wants to manage the extraction externally, and also I restarting the services should be related to .crt and .key files, not to acme.json. Does it make sense to you? |
My understanding is the certs content is available in the
You can use a bind volume mount instead of a data volume. Or mount to a different location in the container and add a symlink to the Likewise you can mount a data volume in the reverse direction, although it's a hassle and I don't recommend it, it would allow you to bindmount read-only the I'd personally advise the symlink approach if you insist on using a data volume instead of a bind mount.
Delay that to a follow up please. |
This comment has been minimized.
This comment has been minimized.
No, you just need to read the
This is a feature that other users (including a maintainer) wants, I would remove it otherwise. You are welcome to handle
That is something I want myself, but I have quite a bit to do, and only have so much time for We can probably leverage @NorseGaud work on
It is optional.... don't provide an
AFAIK, that is supported.
Please open a feature request and ping me. This is an old PR you've bumped and it notifies all participants previously involved. I don't think it's appropriate to continue this discussion here. Thank you. |
Will extract certificates from acme.json as written by traefik v2 for usage in dovecot and postfix.
Also watches acme.json for changes.
For this to work the file has to be mounted/present at
/etc/letsencrypt/acme.jsonThis suppose to replace #976 and fix #1525