Files
ez-api/.env.example
zenfun 9cfc1b2c97 docs(config): document new internal auth and balancer variables
Update .env.example with new configuration options:
- EZ_INTERNAL_ALLOW_ANON for controlling anonymous internal access
- EZ_BALANCER_ENABLE_TEST_KEYS for testing auth bypass
- EZ_BALANCER_TRUSTED_PROXIES for real IP resolution

Add security configuration section to README explaining internal endpoint
authentication logic and default behaviors.
2026-01-03 16:52:23 +08:00

54 lines
2.2 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Control Plane
EZ_API_PORT=8080
EZ_PG_DSN=host=postgres user=postgres password=postgres dbname=ezapi port=5432 sslmode=disable
# 日志库 DSN可选默认不创建独立 log DB留空将使用主库写日志
EZ_LOG_PG_DSN=
EZ_REDIS_ADDR=redis:6379
EZ_REDIS_PASSWORD=
EZ_REDIS_DB=0
EZ_ADMIN_TOKEN=admin123
EZ_INTERNAL_STATS_TOKEN=internal123
# 是否允许匿名访问 /internal/* 端点(仅限开发/测试环境,生产环境应设为 false
# 默认 false空 token 且未配置 EZ_INTERNAL_STATS_TOKEN 时返回 401
EZ_INTERNAL_ALLOW_ANON=false
EZ_CORS_ALLOW_ORIGINS=*
# 日志保留策略(单位:天 / 条数)
EZ_LOG_RETENTION_DAYS=30
EZ_LOG_MAX_RECORDS=1000000
# 日志分区off/month/day
EZ_LOG_PARTITIONING=off
# 同步可靠性CP -> Redis outbox
EZ_SYNC_OUTBOX_ENABLED=true
EZ_SYNC_OUTBOX_INTERVAL_SECONDS=5
EZ_SYNC_OUTBOX_BATCH_SIZE=200
EZ_SYNC_OUTBOX_MAX_RETRIES=10
# Swagger UI Host (留空则使用相对路径,适合反向代理部署)
# 示例: EZ_SWAGGER_HOST=api.example.com 或 EZ_SWAGGER_HOST=localhost:8080
EZ_SWAGGER_HOST=
# Log DB (docker-compose log-postgres可选默认不启用独立日志库)
LOG_POSTGRES_USER=postgres
LOG_POSTGRES_PASSWORD=postgres
LOG_POSTGRES_DB=ezapi_logs
# Data Plane
EZ_BALANCER_PORT=8081
# 是否允许 sk-test* 前缀的测试 Token 绕过鉴权(仅限开发/测试环境)
EZ_BALANCER_ENABLE_TEST_KEYS=false
# 可信反向代理 IP/CIDR 列表(逗号分隔),用于正确解析客户端 IP
# 仅当 RemoteAddr 命中可信代理时才信任 X-Real-IP 和 X-Forwarded-For 头
# 示例: EZ_BALANCER_TRUSTED_PROXIES=10.0.0.0/8,192.168.1.1
EZ_BALANCER_TRUSTED_PROXIES=
EZ_BALANCER_LOG_SINK_ENABLED=false
EZ_BALANCER_LOG_SINK_BASE_URL=http://ez-api:8080
EZ_BALANCER_LOG_SINK_TIMEOUT_SECONDS=3
EZ_BALANCER_STATS_FLUSH_ENABLED=false
EZ_BALANCER_STATS_FLUSH_BASE_URL=http://ez-api:8080
EZ_BALANCER_STATS_FLUSH_TOKEN=internal123
EZ_BALANCER_STATS_FLUSH_INTERVAL_SECONDS=300
EZ_BALANCER_STATS_FLUSH_BATCH_SIZE=200
EZ_BALANCER_STATS_FLUSH_TIMEOUT_SECONDS=5
# 按 provider type 配置非流式请求超时JSON
EZ_BALANCER_TIMEOUT_BY_PROVIDER={"default":30,"openai":40,"compatible":40,"anthropic":50,"claude":50,"google":60}