Add SSL support for PostgreSQL connections
- Add DATABASE_SSL and DATABASE_SSL_VERIFY environment variables - Configure Postgrex to use SSL with optional certificate verification - Allow connecting to PostgreSQL with self-signed certificates
This commit is contained in:
parent
29a811adf2
commit
31b2f8fb91
2 changed files with 57 additions and 31 deletions
10
CLAUDE.md
10
CLAUDE.md
|
|
@ -232,4 +232,12 @@ The application uses distributed Erlang clustering to ensure only one APRS-IS co
|
||||||
4. **Deployment**:
|
4. **Deployment**:
|
||||||
- Default replicas: 3 (configurable in `aprs-deployment.yaml`)
|
- Default replicas: 3 (configurable in `aprs-deployment.yaml`)
|
||||||
- Only leader processes APRS packets
|
- Only leader processes APRS packets
|
||||||
- All nodes serve web traffic
|
- All nodes serve web traffic
|
||||||
|
|
||||||
|
## 1Password Integration
|
||||||
|
|
||||||
|
When working with passwords and secrets:
|
||||||
|
- **ALWAYS** use 1Password account ID: `YOOATCZZSVGH7AD6VABUVPORLI`
|
||||||
|
- Store all passwords, API keys, and secrets in 1Password
|
||||||
|
- Use the `op` CLI tool for programmatic access
|
||||||
|
- Never hardcode passwords in configuration files
|
||||||
|
|
@ -105,37 +105,55 @@ if config_env() == :prod do
|
||||||
adapter: Resend.Swoosh.Adapter,
|
adapter: Resend.Swoosh.Adapter,
|
||||||
api_key: System.get_env("RESEND_API_KEY")
|
api_key: System.get_env("RESEND_API_KEY")
|
||||||
|
|
||||||
|
# Parse SSL configuration from environment
|
||||||
|
ssl_enabled = System.get_env("DATABASE_SSL", "false") == "true"
|
||||||
|
ssl_verify = System.get_env("DATABASE_SSL_VERIFY", "true") == "true"
|
||||||
|
|
||||||
|
ssl_opts = if ssl_enabled do
|
||||||
|
if ssl_verify do
|
||||||
|
[ssl: true]
|
||||||
|
else
|
||||||
|
[ssl: true, ssl_opts: [verify: :verify_none]]
|
||||||
|
end
|
||||||
|
else
|
||||||
|
[]
|
||||||
|
end
|
||||||
|
|
||||||
config :aprsme, Aprsme.Repo,
|
config :aprsme, Aprsme.Repo,
|
||||||
# ssl: true,
|
Keyword.merge(
|
||||||
url: database_url,
|
[
|
||||||
# Increased pool size for better concurrency (was 25)
|
url: database_url,
|
||||||
pool_size: String.to_integer(System.get_env("POOL_SIZE") || "45"),
|
# Increased pool size for better concurrency (was 25)
|
||||||
# Increased timeout for ARM system under load
|
pool_size: String.to_integer(System.get_env("POOL_SIZE") || "45"),
|
||||||
pool_timeout: String.to_integer(System.get_env("POOL_TIMEOUT") || "10000"),
|
# Increased timeout for ARM system under load
|
||||||
# Match PostgreSQL statement timeout capabilities
|
pool_timeout: String.to_integer(System.get_env("POOL_TIMEOUT") || "10000"),
|
||||||
timeout: String.to_integer(System.get_env("DB_TIMEOUT") || "30000"),
|
# Match PostgreSQL statement timeout capabilities
|
||||||
socket_options:
|
timeout: String.to_integer(System.get_env("DB_TIMEOUT") || "30000"),
|
||||||
maybe_ipv6 ++
|
socket_options:
|
||||||
[
|
maybe_ipv6 ++
|
||||||
# TCP optimizations for better connection handling
|
[
|
||||||
keepalive: true,
|
# TCP optimizations for better connection handling
|
||||||
nodelay: true,
|
keepalive: true,
|
||||||
recbuf: 8192,
|
nodelay: true,
|
||||||
sndbuf: 8192
|
recbuf: 8192,
|
||||||
],
|
sndbuf: 8192
|
||||||
types: Aprsme.PostgresTypes,
|
],
|
||||||
# Reduced queue target for faster response
|
types: Aprsme.PostgresTypes,
|
||||||
queue_target: 100,
|
# Reduced queue target for faster response
|
||||||
# Check queue more frequently
|
queue_target: 100,
|
||||||
queue_interval: 1_000,
|
# Check queue more frequently
|
||||||
# Optimize for unnamed prepared statements (better for dynamic queries)
|
queue_interval: 1_000,
|
||||||
prepare: :unnamed,
|
# Optimize for unnamed prepared statements (better for dynamic queries)
|
||||||
# Connection parameters to leverage PostgreSQL settings
|
prepare: :unnamed,
|
||||||
# Note: When using PgBouncer, only certain parameters are supported
|
# Connection parameters to leverage PostgreSQL settings
|
||||||
parameters: [
|
# Note: When using PgBouncer, only certain parameters are supported
|
||||||
# Application name for monitoring
|
parameters: [
|
||||||
application_name: "aprsme"
|
# Application name for monitoring
|
||||||
]
|
application_name: "aprsme"
|
||||||
|
]
|
||||||
|
],
|
||||||
|
ssl_opts
|
||||||
|
)
|
||||||
|
|
||||||
config :aprsme, AprsmeWeb.Endpoint,
|
config :aprsme, AprsmeWeb.Endpoint,
|
||||||
url: [host: host, port: 443, scheme: "https"],
|
url: [host: host, port: 443, scheme: "https"],
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue