#pConfigFile
코드 기반 설정: 내보내기, 계획, 적용 및 Git 파이프라인
Git에 YAML 파일로 관리되는 전체 서버 상태: 테넌트, 도메인(DKIM 셀렉터, MTA-STS, 라우팅), 별칭, 전달 및 부재중 통지 기능이 있는 사서함, 배포 목록, 공유 사서함, 회의실, GAL 및 리소스 규칙, 공유 및 위임, SMTP, 스마트 호스트, 라우팅, 전송 규칙, 스팸 및 바이러스 보호, 방화벽 및 자동 차단, TLS, ID 소스, API 키(메타데이터만), 웹훅, 알림, 운영 경고, POP3, 파일, 예약, 아카이브 및 DNS 페일오버. nextxch-cli config plan은 terraform plan과 같이 생성, 변경 및 삭제될 항목을 미리 보여주며, apply는 모든 것을 먼저 검사한 후 고정된 순서로 적용합니다. 관리자: 시스템 > 구성 파일(System > Configuration as a file).
비밀 정보는 파일에 저장되지 않으며 내보내지지 않습니다. 비밀번호, 토큰 및 키는 secretRef: {env: NAME} 또는 secretRef: {file: path}로 작성되며 적용 시점에 해결됩니다(CI 러너의 nextxch-cli에 의해, 서버에서는 NEXTXCH_SECRET_* 변수 및 <data>/secrets/ 하위 파일만 해당). DKIM 키, 인증서 및 비밀번호 해시는 서버에 유지됩니다. API v1과 같은 비즈니스 기능이며, JSON 스키마는 무료입니다.
1. 파일 형식: apiVersion, kind, metadata.name, spec
여러 문서가 포함된 파일 1개(---로 구분) 또는 영역별 파일이 하나씩 있는 폴더(config export --split). 파일에 누락된 필드는 서버의 기존 상태를 유지하며, 목록(별칭, 구성원)은 전체 단위로 처리됩니다.
# yaml-language-server: $schema=https://nextxch.com/schemas/nextxch-config-v1.schema.json
apiVersion: nextxch/v1
kind: Manifest # optional: areas in which --prune may delete
metadata: {name: nextxch}
spec: {areas: [domains, accounts, sharing, transport]}
---
apiVersion: nextxch/v1
kind: Domain
metadata: {name: company.com}
spec:
tenant: default
catchAll: info@company.com
dkim: {mode: dual, rsaSelector: s2026, ed25519Selector: ed2026} # keys stay on the server
mtaSts: {mode: enforce, maxAgeSeconds: 604800, mxHosts: [mail.company.com]}
---
apiVersion: nextxch/v1
kind: Account
metadata: {name: anna.smith@company.com}
spec:
displayName: Anna Smith
role: User # User, TenantAdmin, ServerAdmin, ComplianceAuditor
quotaMb: 10240
aliases: [anna@company.com]
forwarding: {address: anna@private.example, keepCopy: true}
outOfOffice: {enabled: false}
password: {secretRef: {env: ANNA_PASSWORD}} # never the password itself
---
apiVersion: nextxch/v1
kind: Account
metadata: {name: info@company.com}
spec: {type: shared, displayName: Info mailbox} # user, shared, room, equipment
---
apiVersion: nextxch/v1
kind: Share
metadata: {name: "info@company.com/mailbox -> anna.smith@company.com"}
spec: {permissions: [read, write, sendAs]}
---
apiVersion: nextxch/v1
kind: SmtpSettings
metadata: {name: server} # server-wide settings are always named "server"
spec:
outboundSmartHost: smtp.provider.example
outboundSmartPort: 587
smartHostPassword: {secretRef: {file: secrets/smarthost.txt}}
2. nextxch-cli 워크플로
먼저 내보내고 커밋한 후 풀 리퀘스트를 통해 변경하세요. 예시 계획 출력:
export NEXTXCH_URL=https://mail.company.com
export NEXTXCH_API_KEY=smk_... # key with config.read or config.write
nextxch-cli config export --split nextxch/
nextxch-cli config validate -f nextxch/ # offline: kinds and fields
nextxch-cli config plan -f nextxch/
~ Domain company.com
mtaSts.mode: "testing" -> "enforce"
~ Account anna.smith@company.com
quotaMb: 10240 -> 20480
aliases: ["anna@company.com"] -> ["a.smith@company.com","anna@company.com"]
~ password: (secret changed)
+ Account info@company.com
type: "shared"
displayName: "Info mailbox"
Not in the file (1), deleted only with --prune:
Account old@company.com
Plan: 1 to create, 2 to update, 0 to delete, 41 unchanged.
# exit code 2 = changes
nextxch-cli config apply -f nextxch/ --prune --yes
nextxch-cli config history
3. GitHub Actions: 풀 리퀘스트 시 계획, 병합 시 적용
주석 단계가 포함된 전체 파일: 리포지토리의 deploy/gitops/github-actions.yml. API 키는 파일이 아닌 리포지토리 시크릿에서 가져옵니다.
name: nextxch config
on:
pull_request: {paths: ["nextxch/**"]}
push: {branches: [main], paths: ["nextxch/**"]}
permissions: {contents: read, pull-requests: write}
concurrency: {group: nextxch-config, cancel-in-progress: false}
env: {NEXTXCH_IMAGE: "nextxch/server:latest"}
jobs:
plan:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Plan
env:
NEXTXCH_URL: ${{ vars.NEXTXCH_URL }}
NEXTXCH_API_KEY: ${{ secrets.NEXTXCH_CONFIG_READ_KEY }}
run: |
set +e
docker run --rm -e NEXTXCH_URL -e NEXTXCH_API_KEY -e NO_COLOR=1 -v "$PWD:/work" -w /work \
--entrypoint nextxch-cli "$NEXTXCH_IMAGE" config plan -f nextxch/ --prune > plan.txt 2>&1
code=$?; cat plan.txt; [ "$code" -ne 1 ]
# danach: actions/github-script postet plan.txt als Kommentar (siehe deploy/gitops)
apply:
if: github.event_name == 'push'
runs-on: ubuntu-latest
environment: production
steps:
- uses: actions/checkout@v4
- env:
NEXTXCH_URL: ${{ vars.NEXTXCH_URL }}
NEXTXCH_API_KEY: ${{ secrets.NEXTXCH_CONFIG_WRITE_KEY }}
SMARTHOST_PASSWORD: ${{ secrets.SMARTHOST_PASSWORD }}
run: |
docker run --rm -e NEXTXCH_URL -e NEXTXCH_API_KEY -e SMARTHOST_PASSWORD -v "$PWD:/work" -w /work \
--entrypoint nextxch-cli "$NEXTXCH_IMAGE" config apply -f nextxch/ --prune --yes
4. GitLab CI: 병합 요청 노트로 계획, 기본 브랜치에 적용
전체 파일: deploy/gitops/gitlab-ci.yml. 키는 마스킹 및 보호된 CI/CD 변수이며, resource_group은 동시 실행 적용을 방지합니다.
stages: [validate, plan, apply]
variables: {CONFIG_DIR: nextxch, NO_COLOR: "1"}
.nextxch-cli:
image: {name: "nextxch/server:latest", entrypoint: [""]}
validate:
extends: .nextxch-cli
stage: validate
script: [nextxch-cli config validate -f "$CONFIG_DIR"]
plan:
extends: .nextxch-cli
stage: plan
rules: [{if: '$CI_PIPELINE_SOURCE == "merge_request_event"'}]
variables: {NEXTXCH_API_KEY: $NEXTXCH_CONFIG_READ_KEY}
script:
- set +e
- nextxch-cli config plan -f "$CONFIG_DIR" --prune > plan.txt 2>&1; code=$?
- cat plan.txt; test "$code" -ne 1
artifacts: {when: always, paths: [plan.txt]}
# plan-comment: curl auf /merge_requests/:iid/notes mit plan.txt (siehe deploy/gitops)
apply:
extends: .nextxch-cli
stage: apply
resource_group: nextxch-config
environment: production
rules: [{if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'}]
variables: {NEXTXCH_API_KEY: $NEXTXCH_CONFIG_WRITE_KEY}
script: [nextxch-cli config apply -f "$CONFIG_DIR" --prune --yes]
5. 편집기 및 REST 호출의 JSON 스키마
VS Code(Red Hat "YAML" 확장 프로그램) 및 JetBrains IDE는 입력하는 동안 파일을 검사합니다. 모든 서버는 /api/v1/config/schema에서도 스키마를 제공합니다.
# .vscode/settings.json
{
"yaml.schemas": {
"https://nextxch.com/schemas/nextxch-config-v1.schema.json": ["nextxch/*.yaml"]
}
}
# Plan ohne CLI, direkt per REST (YAML als Body):
curl -s -X POST "$NEXTXCH_URL/api/v1/config/plan?prune=true" \
-H "Authorization: Bearer $NEXTXCH_API_KEY" \
-H "Content-Type: application/yaml" --data-binary @nextxch.yaml
6. 재시작 없는 목록 내 시크릿 및 ACME
파이프라인의 인증 헤더 및 HMAC 비밀이 포함된 MTA 훅, 웹훅 비밀이 포함된 경고 대상, 그리고 DNS-01을 사용하는 Let's Encrypt 전환 스위치: 단 한 번의 적용, 재시작 없음.
apiVersion: nextxch/v1
kind: MtaFilters
metadata: {name: server}
spec:
hooks:
- name: spamcheck
url: https://hooks.company.com/check
stages: [data]
authHeaderName: Authorization
authHeaderValue: {secretRef: {env: HOOK_TOKEN}} # in the plan: hooks[spamcheck].authHeaderValue
hmacSecret: {secretRef: {file: secrets/hook-hmac.txt}}
---
apiVersion: nextxch/v1
kind: OpsAlerts
metadata: {name: server}
spec:
targets:
- name: pager
type: webhook
address: https://pager.company.com/hook
secret: {secretRef: {env: PAGER_SECRET}}
---
apiVersion: nextxch/v1
kind: TlsSettings
metadata: {name: server}
spec:
acme:
enabled: true
directoryUrl: https://acme-v02.api.letsencrypt.org/directory
contactEmail: postmaster@company.com
challenge: Dns01
renewBeforeExpiryDays: 30
설정, 기본값 및 모범 사례
| 설정 / 위치 | 설명 | 기본값 | 프로덕션 모범 사례 |
|---|---|---|---|
config export [--area a,b] [--split ordner/] [-o datei] |
서버 상태를 결정론적으로 내보내기: 고정된 문서 순서, 정렬된 목록, 타임스탬프 없음. 두 번 내보내면 동일한 바이트가 생성되며 Git 차이점(diff)에는 실제 변경 사항만 표시됩니다. | alle Bereiche |
리포지토리에 --split 사용(영역별 파일 하나: domains.yaml, 승인된 accounts.yaml ...); 작은 풀 Requests는 읽기 쉽습니다. |
config plan -f datei|ordner [--prune] |
객체별 표시 + 생성, ~ 업데이트(필드: 이전 -> 신규) 및 - 삭제. 종료 코드 0 = 변경 사항 없음, 2 = 변경 사항 있음, 1 = 오류. 보안 비밀은 "(보안 비밀 변경됨)"으로만 표시됩니다. | ohne Löschen |
풀 리퀘스트에서 실행하고 댓글로 게시합니다( 아래 예시). |
config apply -f ... [--prune] [--yes] [--force] [--dry-run] |
모든 항목을 먼저 검사한 후(필드, 참조, 보안 설정, 안전 규칙), 정해진 순서대로 생성 및 업데이트(테넌트, 도메인, 계정, 메일링 리스트, 규칙, 공유, 전송 등)를 수행하고 역순으로 삭제합니다. 단계가 실패하면 완료된 단계도 롤백됩니다. 모든 변경 사항은 감사 로그에 기록됩니다. | fragt nach |
파이프라인에서는 항상 --yes를 전달하십시오. 터미널이 없으면 apply가 거부됩니다. --dry-run은 plan과 동일합니다. |
--prune und Manifest |
삭제는 --prune을 사용할 때 그리고 매니페스트 문서에 명시된 영역에서만 발생합니다(매니페스트가 없는 경우 파일에 존재하는 유형만 해당). 서버 설정은 절대 삭제되지 않습니다. | aus |
내보내기는 매니페스트를 작성합니다. 일부만 관리하는 경우 범위를 좁히십시오. |
Schutz: letzter Admin, Domain mit Postfächern |
활성 서버 관리자가 남지 않게 되는 플랜이나 여전히 사서함이 있는 도메인의 삭제는 거부됩니다. --force를 사용하면 이를 무시할 수 있습니다(이 경우 도메인은 삭제되는 대신 비활성화됩니다). 자체 API 키는 자기 자신을 취소할 수 없습니다. | aktiv |
파이프라인에 --force를 하드코딩하지 마십시오. |
secretRef: {env: NAME} | {file: pfad} |
값 대신 시크릿에 대한 참조. nextxch-cli는 러너에서 이를 해결합니다(구성 상대의 모든 변수, 파일). 서버 자체는 NEXTXCH_SECRET_* 및 <data>/secrets/ 아래의 파일만 읽습니다. 동일한 값을 다시 적용해도 변경 사항이 없습니다. | - |
GitHub/GitLab 시크릿 저장소의 시크릿을 환경 변수로 작업에 전달합니다. |
Scopes config.read / config.write |
REST: GET /api/v1/config/export, POST /api/v1/config/plan, POST /api/v1/config/apply, GET /api/v1/config/history, GET /api/v1/config/schema (무료). 키: 테넌트 통합 키. 생성자가 여전히 관리자인 동안에만 작동합니다. 서버 관리자의 키는 전체 서버를 볼 수 있고, 테넌트 관리자의 키는 해당 테넌트만 볼 수 있습니다. export 및 plan에는 config.read로 충분하며, apply에는 config.write가 필요합니다. | - |
두 개의 키: 풀 요청의 플랜용 config.read, 메인 브랜치의 적용 작업용으로만 사용되며 가능하면 러너 IP로 제한되는 config.write. |
Mandanten-Admins |
테넌트 관리자(세션 또는 해당 키 중 하나)는 도메인(변경만 가능, 생성 또는 삭제 불가), 계정, 배포 목록, 공유, GalVisibilityRule, ResourceAccessRule 및 웹훅 등 자신의 테넌트 개체만 내보내고, 계획하고, 적용할 수 있습니다. 서버 설정, 테넌트, ID 소스 및 API 키는 서버 관리자가 관리하며, ServerAdmin 또는 ComplianceAuditor 역할을 가진 계정은 접근할 수 없습니다. --prune은 자신의 테넌트 내부의 항목만 삭제하며, 기록에는 자신의 적용 내역만 표시됩니다. | - |
리셀러 및 부서용: 각 테넌트는 자신만의 키를 가진 자체 리포지토리를 유지합니다. "tenant" 필드는 비워둘 수 있으며, 이 경우 자체 테넌트로 채워집니다. |
secretRef in Listen |
목록 항목은 secretRef를 통해 시크릿도 허용합니다: MtaFilters hooks[].authHeaderValue 및 hooks[].hmacSecret, OpsAlerts targets[].secret(웹훅 대상의 HMAC). 요금제는 id 또는 name으로 항목을 명명합니다(예: hooks[spamcheck].authHeaderValue). 목록의 일반 값은 거부됩니다. | - |
id가 없는 항목에는 최초 적용 시 id가 부여됩니다. 내보내기 후 파일의 id를 유지하면 목록이 재정렬되어도 시크릿이 올바른 항목에 유지됩니다. |
ACME zur Laufzeit |
TlsSettings.acme(활성화됨, directoryUrl, contactEmail, 챌린지 Http01/TlsAlpn01/Dns01, renewBeforeExpiryDays, reusePrivateKeyForDane)는 재시작 없이 적용됩니다. appsettings.json은 기본값으로 유지되고 차이점은 <data>/acme-settings.json에 저장되며 전체 클러스터에 적용됩니다. 디렉토리 URL을 변경하면 다음 주문 시 새로운 ACME 계정이 생성됩니다. | appsettings.json |
Let's Encrypt 스테이징 디렉터리로 먼저 테스트한 후 프로덕션으로 전환하십시오. |
Arten (kinds) |
Tenant, Domain, Account, DistributionList, GalVisibilityRule, ResourceAccessRule, Share, SmtpSettings, Route, TransportRules, SpamFilter, MtaFilters, FirewallRule, TlsSettings, IdentitySource, ApiKey, Webhook, Notifications, OpsAlerts, DnsFailover, Pop3, FileStorage, Booking, ArchivePolicy. 모든 필드: JSON Schema. | - |
API 키는 파일에서 생성되지 않으며(비밀 키는 한 번만 존재함), 파일 변경 시 레이블과 스코프가 변경되고 --prune으로 취소됩니다. 회의실 및 예약 설정은 모든 클러스터 노드에서 동일합니다. |