mirror of
https://github.com/axllent/mailpit.git
synced 2026-04-26 00:35:51 +03:00
[GH-ISSUE #286] Configure a Traefik proxy #192
Labels
No labels
awaiting feedback
bug
docker
documentation
enhancement
github_actions
invalid
pull-request
question
stale
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/mailpit#192
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @SimoSca on GitHub (Apr 25, 2024).
Original GitHub issue: https://github.com/axllent/mailpit/issues/286
First of all, thanks for your work!
As requested in https://mailpit.axllent.org/docs/configuration/proxy/, I'll share my custom notes about usage of Traefik Proxy via docker containers.
I have a "global" traefik instance running over the machine, and single docker-compose.yml files with dns services exposed via Traefik, and that's why I'll use the
network_mode: bridge.Traefik tls
You can use traefik to manage the smtp traffic via
tlsonsmtpentrypoint:in this case, you MUST set the smtp port to 25 (that is the traefik entrypoint for smtp) and the hostname
to
my-project-dns-smtp.example.invalidplus thessl/tlsdirective.NOTE:
HostSNI(...)is mandatory and over tls, sotlsdirective/setup (both traefik and smtp client) is mandatorytls(certificates) on portsmpt, then pass the traffic to the service withouttls, so the service don't need to manage certificatesstarttlsconnection doesn't work with traefik, so you must usetlsdirective or no secure connection (tested also inpassthroughmode)As another case, you can use traefik simply as passthrough, so the service manages the certificates:
as you can see, with
passthroughdirective, we moved the effort to the "mailpit" service, so the service must manage the certificates.STARTTLS
If you want to use
starttlsto secure your connection, you must exclude traefik, and contact directly the service:In this case you must configure the client to work with
starttls, point to port1025and hostnamemy-project-dns-smtp.example.invalid.IMPORTANT
Alternatively to explicit mount, you could create a custom private image with the certificates inside, and with default environment variables
MP_SMTP_TLS_CERTandMP_SMTP_TLS_KEYpointing to the certificates inside the image.@axllent commented on GitHub (Apr 25, 2024):
Thanks @SimoSca! Can you please confirm for me that the websocket connections works with this setup? The easy way to tell is whether the icon to the left of "Inbox" (in the side navigation) is an envelope, or a reload (circle with an arrow).
@SimoSca commented on GitHub (Apr 26, 2024):
Hi @axllent , yes, I confirm that websocket works with this setup.
@axllent commented on GitHub (Apr 26, 2024):
Awesome, thanks so much for the notes and confirmation. I have added this to the website so others can reference it 👍
@jortizbs commented on GitHub (Jun 10, 2024):
Hello @axllent and @SimoSca.
I have tried following @SimonSca's documentation, but I have not managed to make it work.
I have configured it using Traefik as TLS handler.
So the Mailpit service does not handle certificates.
I have tried to test it in the following ways:
Without TLS
/mailpit sendmail < email.txt-> works as the documentation statesWith TLS
/mailpit sendmail -S “my-domain-name”:“my-traefik-port” < email.txt-> shows errorUsing sendmail command directly
sendmail -H 'openssl s_client -host “my-domain-name” -port “my-traefik-port -msg” < email.txt-> shows errorUsing openssl command directly
openssl s_client -host “my-domain-name” -port “my-traefik-port -msgIn this case, it seems to connect and Traefik resolves the certificates
The problem is that I can't close the message
Could you please tell me how to test it to verify that it works.
I don't know if I am doing something wrong.
Thank you very much.
@jortizbs commented on GitHub (Jun 10, 2024):
Hi, I have seen what was the problem with openssl, I had to add the Input/Output -crlf option.
That way it allowed me to close the message to send it.
@anasmirza534 commented on GitHub (Dec 17, 2024):
Above config not worked for me on Traefik v3. Lots of trial and error, then finally worked. Sharing reference for others.
label for smtp
need to add smtp entry point into traefik static config, I have added port 1025 both in static config and bound port in docker compose for traefik.