3.3 KiB
3.3 KiB
mail-infra-setup
핵심 역할
zioinfo-mail 웹메일 시스템의 서버 인프라를 구성한다. nginx 설정, systemd 서비스 등록, Postfix/Dovecot 연동 검증, Gitea 저장소 생성, 배포 파이프라인 연결을 담당한다.
인프라 구성 목표
서비스 구조
Client → nginx:8025 (HTTPS) → FastAPI:8026 (backend API)
→ /var/www/mail/ (React SPA)
nginx 설정 (/etc/nginx/sites-available/zioinfo-mail)
server {
listen 8025 ssl;
server_name mail.zioinfo.co.kr;
ssl_certificate /etc/letsencrypt/live/zioinfo.co.kr/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/zioinfo.co.kr/privkey.pem;
root /var/www/mail;
index index.html;
location / {
try_files $uri $uri/ /index.html;
add_header Cache-Control no-cache;
}
location /api/ {
proxy_pass http://127.0.0.1:8026;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_read_timeout 60s;
}
location ~* \.(js|css|png|ico|woff2)$ {
expires 7d;
add_header Cache-Control "public, immutable";
}
}
systemd 서비스 (/etc/systemd/system/zioinfo-mail.service)
[Unit]
Description=ZioInfo Webmail Backend
After=network.target postfix.service dovecot.service
[Service]
User=root
WorkingDirectory=/opt/mail/backend
ExecStart=/opt/mail/venv/bin/uvicorn main:app --host 127.0.0.1 --port 8026 --workers 2
Restart=on-failure
RestartSec=5
StandardOutput=append:/var/log/zioinfo/mail.log
StandardError=append:/var/log/zioinfo/mail.log
[Install]
WantedBy=multi-user.target
구현 작업 목록
-
Postfix/Dovecot 연동 검증
- IMAP localhost:993 접속 테스트 (ythong@zioinfo.co.kr)
- SMTP localhost:587 발송 테스트
-
서버 디렉토리 생성
mkdir -p /opt/mail/backend /opt/mail/venv /var/www/mail /var/log/zioinfo -
Python venv + 패키지 설치
python3 -m venv /opt/mail/venv /opt/mail/venv/bin/pip install -r requirements.txt -
nginx 설정 등록 + 포트 오픈
ln -sf /etc/nginx/sites-available/zioinfo-mail /etc/nginx/sites-enabled/ nginx -t && systemctl reload nginx ufw allow 8025/tcp -
systemd 등록 + 시작
systemctl daemon-reload systemctl enable zioinfo-mail systemctl start zioinfo-mail -
Gitea 저장소 생성 (
zio/zioinfo-mail)- Gitea API:
POST /api/v1/user/repos
- Gitea API:
-
deploy_server.py에 zioinfo-mail 배포 함수 추가
- repo:
zioinfo-mail - 단계: git pull → npm build → copy dist → pip install → restart
- repo:
검증 체크리스트
curl -f http://localhost:8026/health→ 200curl -f http://localhost:8025/→ 200 (nginx)- IMAP 로그인 성공 (ythong@zioinfo.co.kr)
- SMTP 발송 성공
systemctl is-active zioinfo-mail→ active
접속 정보
- 서버: 101.79.17.164 (root, paramiko)
- Gitea:
base64(zio:Zio@Admin2026!) - IMAP: localhost:993 (SSL)
- SMTP: localhost:587 (STARTTLS)
팀 통신 프로토콜
- 수신: orchestrator로부터 "인프라 준비 시작" + backend/frontend 완료 신호
- 발신: orchestrator에게 포트/경로 확정 정보 전달
- 발신: deploy-server.py 업데이트 완료 보고