293 lines
7.1 KiB
Markdown
293 lines
7.1 KiB
Markdown
<p align="center">
|
|
<a href="https://tip.jhammah.com">
|
|
<picture>
|
|
<img src="https://jhammah.com/wp-content/uploads/2025/06/Stalwart_logo1.png" alt="Caddy" width="500">
|
|
</picture>
|
|
</a>
|
|
</p>
|
|
<p align="center">
|
|
<a href="https://tip.jhammah.com">
|
|
<picture>
|
|
<img src="https://jhammah.com/wp-content/uploads/2025/06/Haproxy-logo.png" alt="Caddy" width="500">
|
|
</picture>
|
|
</a>
|
|
</p>
|
|
<p align="center">
|
|
<a href="https://tip.jhammah.com">
|
|
<picture>
|
|
<img src="https://user-images.githubusercontent.com/1128849/210187356-dfb7f1c5-ac2e-43aa-bb23-fc014280ae1f.svg" alt="Caddy" width="500">
|
|
</picture>
|
|
</a>
|
|
</p>
|
|
<p align="center">
|
|
<a href="https://tip.jhammah.com">
|
|
<picture>
|
|
<img src="https://jhammah.com/wp-content/uploads/2025/05/docker-icon.png" alt="Docker" width="175">
|
|
</picture>
|
|
</a>
|
|
</p>
|
|
|
|
<br>
|
|
|
|
<h1 align="center">Install Stalwart Mail Server and protect it with HAProxy (and Caddy) inside Docker Desktop </h1>
|
|
|
|
<br>
|
|
|
|
<br>
|
|
|
|
# Navigation
|
|
|
|
- [Prerequisite](#prerequisite)
|
|
- [Installation](#installation)
|
|
- [docker-compose.yml file](#docker-composeyml-file)
|
|
- [stalwart.yml file](#stalwartyml-file)
|
|
- [roundcube.yml file](#roundcubeyml-file)
|
|
- [Configurations](#configurations)
|
|
- [Stalwart UI First Logon and Configuration](#stalwart-ui-first-logon-and-configuration)
|
|
- [Configuring Caddyfile](#configuring-caddyfile)
|
|
- [Configuring haproxy.cfg file](#configuring-haproxycfg-file)
|
|
- [Configuring Stalwarts .toml file](#configuring-stalwart-toml-file)
|
|
- [Stalwart UI SSL and Domain Configuration](#stalwart-ui-ssl-and-domain-configuration)
|
|
- [Testing Mail Flow](#testint-mail-flow)
|
|
|
|
<br>
|
|
|
|
<br>
|
|
|
|
# Prerequisite
|
|
|
|
**Here are all the things you need to make sure you have before starting this tutorial. I'll eventually be adding links to other relevant tutorials that I create to assist you in completing this tutorial.**
|
|
|
|
<br>
|
|
|
|
**1. You should already have Caddy installed and fully working.**
|
|
|
|
**2. You should already have a Cloudflare account managing your domain.**
|
|
|
|
**3. You should already have a Cloudflare API Token.**
|
|
|
|
**4. You should already have the CNAME records 'mail.yourdomain.com' & 'webmail.yourdomain.com' created.**
|
|
|
|
**5. You should already have your Caddyfile routing 'mail.yourdomain.com' to port 8404.**
|
|
|
|
**6. You should already have your Caddyfile routing 'webmail.yourdomain.com' to port 680.**
|
|
|
|
**7. You should already have an smtp2go.com account created and setup.**
|
|
|
|
**8. You should use an advanced text editor like Notepadd++ or something like it that's designed for coding.**
|
|
|
|
**9. You should already have ports 25, 80, 110, 143, 443, 465, 587, 993, & 4190 opened inside your router pointing to your host machine's IP address.**
|
|
|
|
<br>
|
|
|
|
<br>
|
|
|
|
# Installation
|
|
|
|
<br>
|
|
|
|
## docker-compose.yml file
|
|
|
|
* **This is the docker-compose.yml file that you will use to create your container. It will be installing HAProxy and then including Stalwart and Roundcube's yml files, installing them afterwards.**
|
|
|
|
* **The container will be named "haproxy"**
|
|
|
|
* **It's always going to restart unless we manually stop it.**
|
|
|
|
* **It's volume where the haproxy.cfg file is located will be mapped to the current directory of the yml file.**
|
|
|
|
* **We are adding this container to a custom network called "hap-network" that we'll create below. It's also being assigned a static IP address.**
|
|
|
|
* **Ports 25, 80, 110, 143, 443, 465, 587, 993, & 4190 will be assigned and mapped to this container**
|
|
|
|
* **We're also making HAProxy's container depend on Stalwart's container**
|
|
|
|
* **And finally we are creating a custom "hap-network" for all of these containers. Read the comments in the file and make any changes if needed.**
|
|
|
|
<p align="center">
|
|
<a href="https://tip.jhammah.com">
|
|
<picture>
|
|
<img src="URL GOES HERE" alt="IMAGE GOES HERE" width="1280">
|
|
</picture>
|
|
</a>
|
|
</p>
|
|
|
|
<br>
|
|
|
|
<br>
|
|
|
|
## stalwart.yml file
|
|
|
|
* **This is the stalwart.yml file. - IMPORTANT NOTE - The image was renamed by Stalwart recently so the image that we're pulling in the video is outdated. But don't worry, I updated the files that you can download.**
|
|
|
|
* **The container will be named "stalwart"**
|
|
|
|
* **It's always going to restart unless we manually stop it.**
|
|
|
|
* **Port 7080 will be assigned and mapped to this container (instead of 8080 since 8080 is in use already) which is where you can access the Admin UI.**
|
|
|
|
* **Stalwart's volume for its data files will be mapped to the current directory of the yml file.**
|
|
|
|
* **We are adding this container to our custom "hap-network" and assign it a static IP address.**
|
|
|
|
<p align="center">
|
|
<a href="https://tip.jhammah.com">
|
|
<picture>
|
|
<img src="URL GOES HERE" alt="IMAGE GOES HERE" width="1280">
|
|
</picture>
|
|
</a>
|
|
</p>
|
|
|
|
<br>
|
|
|
|
<br>
|
|
|
|
## roundcube.yml file
|
|
|
|
* **This is the roundcube.yml file. It's not required but very recommended as it's a great email client container that you can use for quick testing.**
|
|
|
|
* **The container will be named "roundcube"**
|
|
|
|
* **It's always going to restart unless we manually stop it.**
|
|
|
|
* **Port 680 will be assigned and mapped to this container (instead of 80 since 80 is in use already) which is where you can access the UI.**
|
|
|
|
* **Roundcube's volumes for its database and config files will be mapped to the current directory of the yml file.**
|
|
|
|
* **Roundcube's volumes for its database and config files will be mapped to the current directory of the yml file.**
|
|
|
|
* **We are adding this container to our custom "hap-network".**
|
|
|
|
<p align="center">
|
|
<a href="https://tip.jhammah.com">
|
|
<picture>
|
|
<img src="URL GOES HERE" alt="IMAGE GOES HERE" width="1280">
|
|
</picture>
|
|
</a>
|
|
</p>
|
|
|
|
<br>
|
|
|
|
<br>
|
|
|
|
# Configurations
|
|
|
|
<br>
|
|
|
|
## Stalwart UI First Logon and Configuration
|
|
|
|
* **Stalwart UI First Logon and Configuration**
|
|
|
|
<p align="center">
|
|
<a href="https://tip.jhammah.com">
|
|
<picture>
|
|
<img src="URL GOES HERE" alt="IMAGE GOES HERE" width="1280">
|
|
</picture>
|
|
</a>
|
|
</p>
|
|
|
|
<br>
|
|
|
|
<br>
|
|
|
|
## Configuring Caddyfile
|
|
|
|
* **This is the Caddyfile. This file tells Caddy what and how to do things.**
|
|
|
|
<p align="center">
|
|
<a href="https://tip.jhammah.com">
|
|
<picture>
|
|
<img src="URL GOES HERE" alt="IMAGE GOES HERE" width="1280">
|
|
</picture>
|
|
</a>
|
|
</p>
|
|
|
|
<br>
|
|
|
|
<br>
|
|
|
|
## Configuring haproxy.cfg file
|
|
|
|
* **Configuring haproxy.cfg file**
|
|
|
|
<p align="center">
|
|
<a href="https://tip.jhammah.com">
|
|
<picture>
|
|
<img src="URL GOES HERE" alt="IMAGE GOES HERE" width="1280">
|
|
</picture>
|
|
</a>
|
|
</p>
|
|
|
|
<br>
|
|
|
|
<br>
|
|
|
|
## Configuring Stalwarts .toml file
|
|
|
|
* **Configuring Stalwarts .toml file**
|
|
|
|
<p align="center">
|
|
<a href="https://tip.jhammah.com">
|
|
<picture>
|
|
<img src="URL GOES HERE" alt="IMAGE GOES HERE" width="1280">
|
|
</picture>
|
|
</a>
|
|
</p>
|
|
|
|
<br>
|
|
|
|
<br>
|
|
|
|
## Stalwart UI SSL and Domain Configuration
|
|
|
|
* **Stalwart UI SSL and Domain Configuration**
|
|
|
|
<p align="center">
|
|
<a href="https://tip.jhammah.com">
|
|
<picture>
|
|
<img src="URL GOES HERE" alt="IMAGE GOES HERE" width="1280">
|
|
</picture>
|
|
</a>
|
|
</p>
|
|
|
|
<br>
|
|
|
|
<br>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Testing Mail Flow
|
|
|
|
**Once you have all of the files customized to your liking and all four of them are sitting in the same directory, you'll be ready to launch the yml file.**
|
|
|
|
<br>
|
|
|
|
<H1 align="center">Support the channel so I can make more tutorials!</h1>
|
|
|
|
<H1 align="center"><a href="https://tip.jhammah.com">If this tutorial helped you out, feel free to buy me a coffee!</h1> |