feat: require TLS to PostgreSQL, Valkey and S3

Storage servers accept only TLS 1.3 (pg_hba hostssl / hostnossl reject,
Valkey port 0, S3 gateway HTTPS only) with stand identities postgres,
valkey and s3. Clients trust only the stand CA from [client_tls] ca_file
and check the host name; no switch to disable verification. Processes
exit with code 2 without a CA or with an IP storage address. Temporary
stands, CI and bench/ run on TLS storages; make storage_tls_check adds
negative checks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-18 21:17:49 +03:00
co-authored by Claude Opus 5.5
parent 25f5d981c0
commit 8bca5543fd
56 changed files with 2562 additions and 176 deletions
+91
View File
@@ -26,9 +26,33 @@
# рабочем стенде. Нужен Compose ≥ 2.24 (!reset, !override; secrets из
# environment с uid / mode).
# С change storage-tls хранилища — только TLS: пары postgres, valkey, s3 — их
# сервисам с владельцем — пользователем процесса (postgres и valkey — 999, s3 —
# seaweed 1000; ключ 0400), CA — ещё s3-bootstrap (seaweed 1000) и клиентам на
# образе API (10001); pg_hba.conf — configs (bind mount в основном файле).
services:
postgres:
ports: !reset []
# !override: bind mount pg_hba.conf заменяет configs, volume данных остаётся
volumes: !override
- postgres_data:/var/lib/postgresql
configs:
- source: postgres_hba
target: /etc/postgresql/pg_hba.conf
secrets: !override
- source: ca.crt
uid: "999"
gid: "999"
mode: 0444
- source: postgres.crt
uid: "999"
gid: "999"
mode: 0444
- source: postgres.key
uid: "999"
gid: "999"
mode: 0400
valkey:
ports: !reset []
@@ -36,15 +60,46 @@ services:
configs:
- source: valkey_conf
target: /usr/local/etc/valkey/valkey.conf
secrets: !override
- source: ca.crt
uid: "999"
gid: "999"
mode: 0444
- source: valkey.crt
uid: "999"
gid: "999"
mode: 0444
- source: valkey.key
uid: "999"
gid: "999"
mode: 0400
s3:
ports: !reset []
secrets: !override
- source: ca.crt
uid: "1000"
gid: "1000"
mode: 0444
- source: s3.crt
uid: "1000"
gid: "1000"
mode: 0444
- source: s3.key
uid: "1000"
gid: "1000"
mode: 0400
s3-bootstrap:
volumes: !reset []
configs:
- source: s3_bootstrap
target: /opt/s3/bootstrap.sh
secrets: !override
- source: ca.crt
uid: "1000"
gid: "1000"
mode: 0444
rabbitmq:
ports: !reset []
@@ -61,6 +116,13 @@ services:
configs: &config-toml
- source: config_toml
target: /app/config.toml
# клиентам хранилищ — только CA стенда, владелец app (UID 10001); так же
# у cleaner, relay и worker (алиас YAML с тегом !override не разрешён)
secrets: !override
- source: ca.crt
uid: "10001"
gid: "10001"
mode: 0444
api:
image: *ci-image
@@ -89,16 +151,31 @@ services:
image: *ci-image
volumes: !reset []
configs: *config-toml
secrets: !override
- source: ca.crt
uid: "10001"
gid: "10001"
mode: 0444
relay:
image: *ci-image
volumes: !reset []
configs: *config-toml
secrets: !override
- source: ca.crt
uid: "10001"
gid: "10001"
mode: 0444
worker:
image: *ci-image
volumes: !reset []
configs: *config-toml
secrets: !override
- source: ca.crt
uid: "10001"
gid: "10001"
mode: 0444
haproxy:
ports: !reset []
@@ -184,6 +261,8 @@ configs:
environment: CI_S3_BOOTSTRAP
rabbitmq_conf:
environment: CI_RABBITMQ_CONF
postgres_hba:
environment: CI_POSTGRES_HBA
haproxy_cfg:
environment: CI_HAPROXY_CFG
haproxy_openssl_cnf:
@@ -220,3 +299,15 @@ secrets: !override
environment: CI_PKI_HAPROXY_PEM
ingress.pem:
environment: CI_PKI_INGRESS_PEM
postgres.crt:
environment: CI_PKI_POSTGRES_CRT
postgres.key:
environment: CI_PKI_POSTGRES_KEY
valkey.crt:
environment: CI_PKI_VALKEY_CRT
valkey.key:
environment: CI_PKI_VALKEY_KEY
s3.crt:
environment: CI_PKI_S3_CRT
s3.key:
environment: CI_PKI_S3_KEY
+12 -1
View File
@@ -14,8 +14,10 @@ CI_HAPROXY_CFG="$(cat infra/haproxy/haproxy.cfg)$nl"
# TLS 1.3 на ingress)
CI_HAPROXY_OPENSSL_CNF="$(cat infra/haproxy/openssl.cnf)$nl"
CI_RABBITMQ_CONF="$(cat infra/rabbitmq/rabbitmq.conf)$nl"
# pg_hba.conf стенда (change storage-tls): по сети — только TLS
CI_POSTGRES_HBA="$(cat infra/postgres/pg_hba.conf)$nl"
export CI_CONFIG_TOML CI_VALKEY_CONF CI_S3_BOOTSTRAP CI_HAPROXY_CFG \
CI_HAPROXY_OPENSSL_CNF CI_RABBITMQ_CONF
CI_HAPROXY_OPENSSL_CNF CI_RABBITMQ_CONF CI_POSTGRES_HBA
# наблюдаемость (design change otel-telemetry, решение 20)
CI_OTEL_COLLECTOR="$(cat infra/otel/collector.yaml)$nl"
CI_PROMETHEUS_YML="$(cat infra/otel/prometheus/prometheus.yml)$nl"
@@ -44,6 +46,15 @@ CI_PKI_HAPROXY_PEM="$(cat "$ci_pki_dir/haproxy.pem")$nl"
CI_PKI_INGRESS_PEM="$(cat "$ci_pki_dir/ingress.pem")$nl"
export CI_PKI_CA_CRT CI_PKI_CRL_PEM CI_PKI_API_CRT CI_PKI_API_KEY \
CI_PKI_HAPROXY_PEM CI_PKI_INGRESS_PEM
# серверы хранилищ (change storage-tls): пары postgres, valkey, s3
CI_PKI_POSTGRES_CRT="$(cat "$ci_pki_dir/postgres.crt")$nl"
CI_PKI_POSTGRES_KEY="$(cat "$ci_pki_dir/postgres.key")$nl"
CI_PKI_VALKEY_CRT="$(cat "$ci_pki_dir/valkey.crt")$nl"
CI_PKI_VALKEY_KEY="$(cat "$ci_pki_dir/valkey.key")$nl"
CI_PKI_S3_CRT="$(cat "$ci_pki_dir/s3.crt")$nl"
CI_PKI_S3_KEY="$(cat "$ci_pki_dir/s3.key")$nl"
export CI_PKI_POSTGRES_CRT CI_PKI_POSTGRES_KEY CI_PKI_VALKEY_CRT \
CI_PKI_VALKEY_KEY CI_PKI_S3_CRT CI_PKI_S3_KEY
# готовность стенда через LB: /health/ready отвечает 200 от API_REPLICAS
# (из .env, по умолчанию 2) разных реплик — X-Instance-Id. Срок 60 с: