Security Hardening
Guide: Security Hardening
Section titled “Guide: Security Hardening”Follow this guide after deploying ɳSelf to production. For a quick checklist, see Security-Hardening.
Firewall
Section titled “Firewall”Close all ports except 80, 443, and 22. All internal service ports (Postgres 5432, Hasura 8080, Auth 4000) must not be reachable from the internet.
ufw allow 22/tcpufw allow 80/tcpufw allow 443/tcpufw default deny incomingufw enableufw status verboseRotate Default Secrets
Section titled “Rotate Default Secrets”Before going live, replace all generated default secrets with strong random values:
# Generate strong secrets (32+ characters)openssl rand -hex 32 # use output for each secretSet in .env.secrets:
POSTGRES_PASSWORD=<strong-random>HASURA_GRAPHQL_ADMIN_SECRET=<strong-random>HASURA_JWT_KEY=<strong-random>AUTH_JWT_SECRET=<strong-random>Never commit .env.secrets to git. Verify it is in .gitignore.
Disable Hasura Console in Production
Section titled “Disable Hasura Console in Production”The Hasura GraphQL console exposes schema information and must be disabled in production:
HASURA_GRAPHQL_ENABLE_CONSOLE=falseRebuild after changing:
nself build && nself restartEnable Rate Limiting
Section titled “Enable Rate Limiting”Add rate limiting to Auth endpoints to prevent brute-force attacks. The default rate limit is 30 requests/minute.
To customise:
AUTH_RATE_LIMIT=10r/m # 10 requests per minuteFor WAF-level protection, install the rate-limit plugin:
nself plugin install rate-limitKeep Everything Updated
Section titled “Keep Everything Updated”nself update # update nSelf CLInself build # regenerate configs with latest service imagesnself restart # apply updatesEnable Monitoring and Alerts
Section titled “Enable Monitoring and Alerts”See Guide-Monitoring-Setup for step-by-step instructions. Set up CPU, memory, and error-rate alerts in Alertmanager.
See Also
Section titled “See Also”- Security-Hardening: production checklist
- Security-Architecture: how ɳSelf is secured by design
- Guide-Monitoring-Setup: enable alerts