Running Stalwart behind Caddy #488
Replies: 8 comments 24 replies
-
The reason I created this setup is that in this way you can have both mail and http running at the root-domain. www is redirected to the root and webmin is running behind mail.domain.tld. Now you can start a small VM for every venture or cool idea that you think of. |
Beta Was this translation helpful? Give feedback.
-
Thank you! I finally got it running with this config |
Beta Was this translation helpful? Give feedback.
-
Could you also tell to which ports your router/firewall points to? 443 for caddy and the rest for stalwart? Or all to caddy? I am still a little confused. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Is there any good way to get caddy to foward the real ip to stalwart to log? |
Beta Was this translation helpful? Give feedback.
-
Does Stalwart automatically reload the certificate if the underlying file changes? The docs suggest it doesn't and that it needs an extra command to reload them, which is missing from this solution. |
Beta Was this translation helpful? Give feedback.
-
Curious about this caddy setup... Were you able to get JMAP to work on this? I had initially had pretty much the same setup as you (except with reference to a docker container instead of local IP), but JMAP didn't work. I had to modify my Caddyfile with a few key changes (8080 to 443 with transport http and and proxy protocol wrapper)... otherwise, a JMAP session could connect but it would return the internal http url on 8080 instead of being over a secure connection and would fail to find any mailboxes. I solved it with Proxy Protocol, but not Layer 4 (I still forward ports 25, 587, 993, and 4190 for non-HTTPS connections). This is based on docker network at {
servers {
listener_wrappers {
proxy_protocol {
timeout 5s
allow 127.0.0.0/8 ::1/128 172.18.0.0/16
fallback_policy ignore
}
tls
}
}
}
# Mail server - for WebDAV/JMAP services
mail.<my domain> {
# Proxy all HTTP traffic to Stalwart's HTTP/CardDAV/JMAP service
reverse_proxy https://stalwart:443 {
transport http {
tls_insecure_skip_verify
}
}
} I put the same trusted domains in the proxy of my global network in Stalwart, and JMAP is now working perfectly. I wanted to offer this as a solution with limited proxy protocol support (which Caddy has out-of-the-box) as long as you are willing to deal with the IMAP/SMTP/ManageSieve ports outside of the reverse proxy. However, if you were able to get JMAP working without doing this, I am curious if I am missing another solution. |
Beta Was this translation helpful? Give feedback.
-
I run the same way, with Caddy taking care of the SSL certificate. But I've automated the renewal of the certificates into the Stalwart directory differently, instead of your daily copy I have added this to my
And
This requires a |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I have managed to get Stalwart to run behind Caddy. There are only a couple of things you have to do.
This is my Caddyfile, yours might differ of course:
After succesfully starting Caddy you can copy the certificate files to your Stalwart dir:
Put the following in root's crontab,it needs to be root because of ownership of different files...
add the following to your config.toml:
Now you can safely (re)start Stalwart and finish configuration in Webmin.
Beta Was this translation helpful? Give feedback.
All reactions