Health endpoints: - /api/health (Journal) and /health (Planner) with DB connectivity check - Docker healthchecks updated to use app health endpoints Structured logging: - Pino with JSON output in production, pretty-print in dev - Request logging middleware in Planner (method, path, status, duration) - Replaced console.log/error with structured logger in email and auth flows Prometheus metrics: - prom-client with default Node.js metrics + custom histograms/gauges - /metrics endpoints on both apps - http_request_duration, planner_active_sessions, brouter_request_duration Monitoring stack: - Prometheus, Loki, Grafana containers in docker-compose - Grafana provisioned with datasources, dashboards, and alert rules - Caddy access logging (JSON to stdout for Loki) - grafana.trails.cool with basic auth via Caddy Dashboards and alerting: - Overview: request rate, error rate, latency p50/p95/p99 - Planner: active sessions, connected clients, BRouter latency - Infrastructure: memory, CPU, event loop lag - Alerts: disk >80%, app down 2min, error rate >5% Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
46 lines
1.2 KiB
Caddyfile
46 lines
1.2 KiB
Caddyfile
(security_headers) {
|
|
header {
|
|
Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
|
|
X-Content-Type-Options "nosniff"
|
|
X-Frame-Options "DENY"
|
|
Referrer-Policy "strict-origin-when-cross-origin"
|
|
Permissions-Policy "camera=(), microphone=(), geolocation=()"
|
|
Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' blob:; worker-src 'self' blob:; style-src 'self' 'unsafe-inline'; img-src 'self' data: https://*.tile.openstreetmap.org; connect-src 'self' wss: https://*.sentry.io https://*.ingest.de.sentry.io; font-src 'self';"
|
|
}
|
|
}
|
|
|
|
(block_scanners) {
|
|
@scanners path /.env* /.git* /wp-* /wp-admin* /admin* /config.* /backup* /.aws* /.docker* /composer* /vendor* *.php *.asp
|
|
respond @scanners 403
|
|
}
|
|
|
|
{$DOMAIN:trails.cool} {
|
|
import security_headers
|
|
import block_scanners
|
|
log {
|
|
output stdout
|
|
format json
|
|
}
|
|
reverse_proxy journal:3000
|
|
}
|
|
|
|
www.{$DOMAIN:trails.cool} {
|
|
redir https://{$DOMAIN:trails.cool}{uri} permanent
|
|
}
|
|
|
|
grafana.{$DOMAIN:trails.cool} {
|
|
basicauth {
|
|
{$GRAFANA_USER:admin} {$GRAFANA_PASSWORD_HASH}
|
|
}
|
|
reverse_proxy grafana:3000
|
|
}
|
|
|
|
planner.{$DOMAIN:trails.cool} {
|
|
import security_headers
|
|
import block_scanners
|
|
log {
|
|
output stdout
|
|
format json
|
|
}
|
|
reverse_proxy planner:3001
|
|
}
|