- Full grant strategy framework for renewable energy & green hydrogen - AI-powered grant studio, partner outreach, financial modeling - Umami analytics with data-performance tracking - Live Degelas metrics connected to solar.degelas.be - Trilingual (EN/FR/AR) with i18n support - Dockerized with Nginx frontend + Express API proxy
11 KiB
Production Hardening Pack — Implementation Summary
Overview
This document summarizes all security, performance, and operational hardening measures implemented for production deployment.
Security Hardening
1. Rate Limiting
File: server/middleware/rateLimit.ts
Implementation:
- API endpoints: 100 requests per 15 minutes per IP
- Health check: 1000 requests per minute (unrestricted for monitoring)
- Nginx layer: 10 requests/second with burst of 20
Benefits:
- Prevents DDoS attacks
- Prevents API abuse
- Protects against brute force
2. Input Validation
File: server/middleware/validate.ts
Implementation:
- Zod schema validation on all API endpoints
- Returns 400 with detailed validation errors
- Prevents injection attacks
Benefits:
- Prevents malformed requests
- Clear error messages for debugging
- Type-safe validation
3. Security Headers
Files: server/index.ts (Helmet), nginx.conf
Headers Implemented:
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
Referrer-Policy: no-referrer-when-downgrade
Content-Security-Policy: default-src 'self' ...
Strict-Transport-Security: max-age=31536000; includeSubDomains
X-Download-Options: noopen
X-Permitted-Cross-Domain-Policies: none
Benefits:
- Prevents clickjacking
- Prevents XSS attacks
- Prevents MIME-type sniffing
- Enforces HTTPS
- Restricts cross-domain policies
4. CORS Hardening
File: server/index.ts
Implementation:
- Configured via
CLIENT_ORIGINenv var - Methods restricted to GET/POST
- Credentials disabled
- Max age 10 minutes
Benefits:
- Prevents unauthorized cross-origin requests
- Reduces attack surface
5. Request Size Limits
Files: server/index.ts, nginx.conf
Limits:
- JSON body: 1MB
- URL-encoded body: 1MB
- Client body buffer: 1MB
- Client max body: 2MB
Benefits:
- Prevents large payload attacks
- Protects against memory exhaustion
6. Sensitive Data Protection
File: server/middleware/logger.ts
Implementation:
- API keys redacted in logs
- Authorization headers redacted
- Cookies redacted
Benefits:
- Prevents credential leakage in logs
- Compliance with security best practices
7. File Access Control
File: nginx.conf
Implementation:
- Hidden files denied (
/.*) - Error pages customized
- Directory listing disabled
Benefits:
- Prevents
.envexposure - Prevents directory traversal
- Reduces information disclosure
Performance Hardening
1. Compression
File: nginx.conf
Implementation:
- Gzip enabled for text-based assets
- Minimum length 1KB
- Vary header for proper caching
Benefits:
- 60-80% bandwidth reduction
- Faster page loads
- Better SEO
2. Caching
File: nginx.conf
Implementation:
- Static assets: 6 months cache
- Immutable flag for fingerprinted assets
- API responses not cached
Benefits:
- Reduced server load
- Faster repeat visits
- Better user experience
3. Timeouts
File: nginx.conf
Timeouts Configured:
- Client body: 12 seconds
- Client header: 12 seconds
- Keepalive: 15 seconds
- Send: 10 seconds
Benefits:
- Prevents slowloris attacks
- Frees up connections faster
- Better resource utilization
4. Buffer Limits
File: nginx.conf
Limits:
- Body buffer: 1MB
- Header buffer: 1KB
- Large headers: 2 x 1KB
Benefits:
- Prevents buffer overflow attacks
- Predictable memory usage
- Protection against malformed requests
Operational Hardening
1. Environment Validation
File: server/lib/env.ts
Implementation:
- Zod schema validation on startup
- Fails fast if required vars missing
- Logs configuration (without secrets)
Benefits:
- Prevents misconfigured deployments
- Clear error messages
- Early detection of issues
2. Structured Logging
File: server/middleware/logger.ts
Implementation:
- Pino logger (JSON format)
- Request ID tracking
- Response time logging
- Redaction of sensitive data
Benefits:
- Easy log aggregation
- Request tracing
- Compliance with logging standards
3. Error Handling
File: server/middleware/errorHandler.ts
Implementation:
- Global error handler
- Sanitized errors in production
- Detailed errors in development
- Request ID in error responses
Benefits:
- No stack traces exposed in production
- Consistent error format
- Easier debugging with request IDs
4. Health Checks
File: server/index.ts, docker-compose.yml
Implementation:
/api/healthendpoint- Docker health check configured
- Service dependencies wait for health
Benefits:
- Monitoring integration
- Automatic restart on failure
- Proper startup ordering
5. Resource Limits
File: docker-compose.prod.yml
Limits:
- API server: 1 CPU, 512MB RAM
- Frontend: 0.5 CPU, 256MB RAM
Benefits:
- Predictable resource usage
- Prevents resource exhaustion
- Better container scheduling
6. Log Rotation
File: docker-compose.prod.yml
Configuration:
- Max size: 10MB per log file
- Max files: 3
- JSON format for parsing
Benefits:
- Prevents disk exhaustion
- Easier log management
- Compliance with log retention
Deployment Hardening
1. Multi-Stage Docker Build
File: Dockerfile
Stages:
- Frontend builder (Node 20 Alpine)
- API builder (Node 20 Alpine)
- Frontend runtime (Nginx Alpine)
- API runtime (Node 20 Alpine)
Benefits:
- Smaller final images
- No dev dependencies in production
- Reduced attack surface
2. Health-Based Dependencies
File: docker-compose.yml
Implementation:
depends_on:
api-server:
condition: service_healthy
Benefits:
- Frontend waits for API to be ready
- Prevents startup race conditions
- Better reliability
3. Restart Policies
File: docker-compose.yml
Policy: unless-stopped
Benefits:
- Automatic recovery from crashes
- Persists across reboots
- Manual stop respected
4. Production Override
File: docker-compose.prod.yml
Features:
- Resource limits
- Log rotation
- Always restart policy
- Production log level
Usage:
docker compose -f docker-compose.yml -f docker-compose.prod.yml up -d
Monitoring & Alerting
1. Health Endpoint
URL: /api/health
Response:
{
"status": "ok",
"timestamp": "2026-01-15T..."
}
Usage:
- Uptime monitoring
- Load balancer health checks
- Kubernetes readiness probes
2. Request Logging
Format: JSON (production)
Fields:
- Request ID
- Method
- Path
- Status code
- Duration
- IP address
- User agent
Usage:
- Log aggregation (ELK, Grafana)
- Performance analysis
- Security auditing
3. Error Tracking
Implementation:
- Structured error logging
- Request ID correlation
- Stack traces in development
Integration:
- Sentry (recommended)
- Log-based alerting
- Custom error dashboards
Backup & Recovery
1. Backup Script
File: backup.sh (in deployment guide)
Backs Up:
.envfile (critical)- Docker Compose config
- Docker volumes (if any)
Retention: 7 days
2. Backup Schedule
Cron: Daily at 2 AM
Command:
0 2 * * * /opt/atlasgreen/backup.sh
3. Restore Procedure
Documented in: DEPLOYMENT_GUIDE_VPS.md
Steps:
- Stop containers
- Restore
.env - Restore config
- Rebuild containers
- Verify health
SSL/TLS Configuration
1. Certificate
Provider: Let's Encrypt (free)
Validity: 90 days (auto-renewal)
Command:
sudo certbot --nginx -d yourdomain.com
2. Nginx SSL Config
File: DEPLOYMENT_GUIDE_VPS.md (example config)
Features:
- TLS 1.2 and 1.3 only
- Strong cipher suites
- Session caching
- HTTP/2 support
3. Auto-Renewal
Test Command:
sudo certbot renew --dry-run
Cron: Twice daily (default)
Access Control
1. SSH Hardening
File: /etc/ssh/sshd_config
Settings:
- Root login: disabled
- Password auth: disabled
- Key-based auth: enabled
- AllowUsers: restricted
2. Firewall
Tool: UFW
Rules:
- SSH (22): allowed
- HTTP (80): allowed
- HTTPS (443): allowed
- All others: denied
3. Fail2Ban
Service: SSH protection
Configuration:
- Max retries: 5
- Ban time: 1 hour
- Find time: 10 minutes
Compliance
GDPR
- Minimal data collection
- No personal data stored by default
- IP addresses in logs (consider retention policy)
- Privacy policy recommended
SOC2 (if applicable)
- Access control via SSH keys
- Change management via Git
- Logging enabled
- Consider adding audit logging
Security Best Practices
- OWASP Top 10 addressed
- CIS Docker Benchmark aligned
- Nginx hardening applied
- Regular updates scheduled
Testing
Security Tests
- SSL Labs test (target: A+)
- OWASP ZAP scan
- Dependency vulnerability scan (Trivy)
- Rate limiting test
- Input validation test
Performance Tests
- Load test (100 concurrent users)
- Response time < 500ms
- Page load < 3 seconds
- Gzip compression verified
Operational Tests
- Health check accessible
- Log rotation working
- Backup script tested
- Restore procedure tested
- Rollback procedure tested
Maintenance
Weekly
- Review error logs
- Check disk space
- Review access logs
Monthly
- Update system packages
- Update Docker images
- Review API keys
- Test backup restoration
Quarterly
- Security audit
- Performance review
- Documentation update
- Firewall rule review
Incident Response
Severity Levels
- P1: Site down, data breach (< 15 min response)
- P2: Major functionality broken (< 2 hours)
- P3: Minor issues (< 24 hours)
- P4: Cosmetic/low priority (< 1 week)
Escalation
- Primary Admin
- Secondary Admin
- External consultant
Communication
- Status page (if applicable)
- Email notifications
- Slack/Teams alerts
Documentation
Created Documents
SECURITY_CHECKLIST.md— Security hardening checklistDEPLOYMENT_GUIDE_VPS.md— Step-by-step deploymentPRODUCTION_READINESS.md— Pre-deployment verificationHARDENING_SUMMARY.md— This documentBACKUP_PROCEDURE.md— Backup and restore procedures
Required Actions
- Fill in emergency contacts
- Configure monitoring alerts
- Test backup restoration
- Document custom configurations
- Train team on procedures
Next Steps
-
Immediate:
- Review all checklists
- Configure monitoring
- Test backup/restore
-
Before Go-Live:
- Complete security tests
- Complete performance tests
- Train support team
-
Post Go-Live:
- Monitor closely for 1 week
- Review logs daily
- Address any issues promptly
Version: 1.0
Date: January 2026
Status: Ready for Production Deployment