# 추후 AWS ec2 인스턴스 임대하여 테스트 해보기로 함.
▶︎ 개요
도커의 메일 오픈소스인 poste를 사용하여 메일 서버를 구축해보려고 합니다.
▶︎ 메일 서버 구축하기
‣ 사전 준비
- Docker
- Docker Compose
- NPM(Nginx Proxy Manager)
- 주로 도커로 사용되는 메일 오픈소스의 경우 nginx를 기본으로 연동하여 사용함.
‣ 도메인 설정
A 레코드, MX 레코드 설정이 되어있어야 합니다.
레코드 | 호스트 | 값 |
---|---|---|
A | @ | 13.125.104.229 |
A | www | 13.125.104.229 |
A | 13.125.104.229 | |
MX | @ | mail.palworldgall.shop. |
도메인 설정을 완료했다면, 네임서버를 조회해봅시다.
nslookup -query=mx palworldgall.shop
output
Server: 127.0.0.53
Address: 127.0.0.53#53
Non-authoritative answer:
palworldgall.shop mail exchanger = 10 mail.palworldgall.shop.
Authoritative answers can be found from:
‣ 방화벽 설정
방화벽에서 아래의 포트들을 개방해줍니다.
Port number | Purpose |
---|---|
25 | SMTP - mostly processing incoming mails from remote mail servers |
80 | HTTP - redirect to https (see options) and authentication for Let's encrypt service |
110 | POP3 - standard protocol for accessing mailbox, STARTTLS is required before client auth |
143 | IMAP - standard protocol for accessing mailbox, STARTTLS is required before client auth |
443 | HTTPS - access to administration or webmail client |
465 | SMTPS - Legacy SMTPs port |
587 | MSA - SMTP port primarily used by email clients after STARTTLS and auth |
993 | IMAPS - alternative port for IMAP with encryption from the start of the connection |
995 | POP3S - POP3 port with encryption from the start of the connection |
4190 | Sieve - remote sieve settings |
‣ 메일 저장용 폴더 생성
서버에서 메일 데이터를 저장할 디렉토리를 생성해줍니다.
mkdir -p ~/dockerMail/data
‣ YAML 작성
컨테이너 배포용 docker-compose.yaml
을 작성해봅시다.
~/dockerMail/docker-compose.yaml
services:
mail:
image: analogic/poste.io:2
restart: always
hostname: mail.palworldgall.shop
ports:
- "25:25" # smtp
- "8181:8181" # http 접속
- "4433:4433" # https 접속
- "110:110" # pop3
- "143:143" # imap
- "465:465" # smtps
- "587:587" # msa
- "993:993" # imaps
- "995:995" # pops
- "4190:4190" # Sieve
volumes:
- "./mail-data:/data" # 호스트 경로에 위에서 만들었던 메일 폴더 경로 지정
environment:
- TZ=Asia/Seoul
- HTTP_PORT=8181
- HTTPS_PORT=4433
networks:
- "mail-net"
networks:
mail-net:
driver: bridge
external: false
아래 명령을 실행하여 컨테이너를 생성해줍시다.
docker-compose up -d --build
‣ 리버스 프록시 설정
‣ 관리자 설정
https::/domain:port
으로 접속하여 관리자로 사용할 아이디와 비밀번호를 생성한 후 접속합니다.
본인의 경우 서브 도메인(poste.palworldgall.shop
을 해당 poste 앱으로 리버스 프록시 되도록 npm에서 설정을 하였으므로,
아래와 같이 접속하였습니다.