email-unlimit/README.md

95 lines
3.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Email Unlimit Project (临时邮件项目)
## 最终架构 (单一 Docker Compose + 宿主机 Nginx)
本项目采用生产环境推荐的架构:所有服务(包括您的应用和完整的 Mailu 邮件套件)都由一个 `docker-compose.full.yml` 文件统一管理,而入口的反向代理则由 **宿主机上的 Nginx** 负责。
- **宿主机 Nginx:** 作为项目的唯一公共入口 (`main.shenjianl.cn`)。它负责:
1. 处理所有外部流量和 SSL 加密(推荐)。
2. 将对域名根路径 (`/`) 的访问反向代理到 **前端 Docker 容器** (`localhost:5181`)。
3. 将对 `/api` 路径的访问反向代理到 **后端 Docker 容器** (`localhost:5182`)。
4. 将对 `/mailu` 路径的访问反向代理到 **Mailu Admin UI** (`localhost:80`)。
- **Docker 容器 (由 `docker-compose.full.yml` 管理):**
- **您的应用:** `frontend`, `backend`, `mysql`
- **Mailu 套件:** `front` (Mailu Nginx), `admin`, `smtp`, `imap`, `redis` 等全套服务。
---
## 如何运行
### 步骤 1: 准备工作
1. **安装 Docker**: 确保您的系统中已安装 Docker 和 Docker Compose。
2. **配置 Mailu**: 打开 `mailu.env` 文件,**务必修改** `SECRET_KEY``ADMIN_PASSWORD` 为安全的值。域名和数据库配置已预填。
3. **配置 DNS**: 根据 `info.md` 中的 DNS 记录示例,在您的域名提供商处完成 SPF、DKIM 和 DMARC 的配置。
### 步骤 2: 配置宿主机 Nginx
将下面的配置块添加到您宿主机的 Nginx 中。这份配置统一处理了对您的应用和 Mailu 管理后台的访问。
```nginx
# /etc/nginx/conf.d/main.shenjianl.cn.conf
server {
listen 80;
server_name main.shenjianl.cn;
# --- 推荐配置 SSL ---
# listen 443 ssl http2;
# server_name main.shenjianl.cn;
# ssl_certificate /path/to/your/fullchain.pem;
# ssl_certificate_key /path/to/your/privkey.pem;
# --------------------
# 反向代理到前端 Vue.js 容器
location / {
proxy_pass http://localhost:5181;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
# 反向代理到后端 API 容器
location /api {
proxy_pass http://localhost:5182;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
# 反向代理到 Mailu Admin UI 和 Webmail
# 注意Mailu 自己的 Nginx (front) 在 80 端口上运行
location /mailu {
proxy_pass http://localhost:80;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
```
**配置完成后,请重载或重启您的 Nginx 服务。**
### 步骤 3: 启动 Docker 服务
使用我们最终生成的 `docker-compose.full.yml` 文件来启动所有服务。
```bash
# 在项目根目录执行
docker-compose -f docker-compose.full.yml up -d --build
```
---
## 访问<E8AEBF><E997AE><EFBFBD>
- **主应用入口**: `http://main.shenjianl.cn`
- **Mailu 管理后台**: `http://main.shenjianl.cn/mailu`
- **Mailu Webmail**: `http://main.shenjianl.cn/mailu/webmail`
docker-compose up -d --build