WishMeLz

生活其实很有趣

CraneMail 优化访问速度之 - Stunnel/HAProxy

HAProxy

haproxy.cfg

global
    log stdout format raw local0
    maxconn 4096

defaults
    mode tcp
    timeout connect 10s
    timeout client 1m
    timeout server 1m

# =============================
# IMAPS - 993 转发
# =============================
frontend imaps_in
    bind *:993
    default_backend imaps_out

backend imaps_out
    server imap_server eu1.workspace.org:993 check


# =============================
# SMTPS - 465 转发
# =============================
frontend smtps_in
    bind *:465
    default_backend smtps_out

backend smtps_out
    server smtp_server eu1.workspace.org:465 check

docker-compose.yml

version: '3.8'

services:
  haproxy:
    image: haproxy:lts
    container_name: haproxy-mail-proxy
    restart: always
    ports:
      - "993:993"   # IMAPS
      - "465:465"   # SMTPS
    volumes:
      - ./haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro