namshi / docker-smtp

SMTP docker container
MIT License
548 stars 199 forks source link

Traefik integration #63

Open hosseinsalemi opened 4 years ago

hosseinsalemi commented 4 years ago

How can I integrate with Traefik for SSL and more?

ptruman commented 4 years ago

Hi

Traefik proxies incoming connections,, not outgoing ones - but you can access the certs generated by Traefik.

#!/bin/sh
jq -r .YOURPROVIDER.Certificates[0].certificate /your/host/path/to/your/traefik/acme.json | base64 -d > /another/path/on/your/host/cert.pem
jq -r .YOURPROVIDER.Certificates[0].key /your/host/path/to/your/traefik/acme.json | base64 -d > /another/path/on/your/host//key.pem

I'm assuming that you

  1. have a volume you use for persistent Traefik storage, which contains acme.json
  2. have a different volume you can use to expose to namshi/smtp
  3. have "jq" installed (it's available to Debian)

I run this nightly as a cron job to extract my certs from Traefik and expose them to other services/containers that need them locally. You'd likely need to issue a docker restart to namshi/smtp also.