KALNET Security Guide
Overview
This document describes the security architecture and best practices for KALNET deployment. Security is implemented in layers:- Network Security - Firewall rules, network isolation
- Container Security - Docker hardening, resource limits
- Authentication - Service access controls
- Secrets Management - Credential handling
- TLS/Encryption - Data in transit protection
Quick Start
Security Architecture
1. Network Security
Firewall Configuration
KALNET uses UFW (Uncomplicated Firewall) for network access control:Port Matrix
| Port | Protocol | Access | Service | Notes |
|---|---|---|---|---|
| 22 | TCP | LAN | SSH | Remote management |
| 80 | TCP | Public | HTTP | Redirects to HTTPS |
| 443 | TCP | Public | HTTPS | Main entry point |
| 139 | TCP | LAN | Samba | NetBIOS |
| 445 | TCP | LAN | Samba | SMB direct |
| 8080 | TCP | LAN | Traefik | Dashboard |
| 9090 | TCP | LAN | Metrics | Prometheus endpoint |
Docker/UFW Compatibility
Docker manipulates iptables directly, which can bypass UFW rules. Apply the Docker UFW fix:Network Isolation
Services communicate via an isolated Docker bridge network:- Services only expose ports to Traefik, not the host
- Samba is an exception (SMB can’t be HTTP-proxied)
- Inter-service communication uses container names
2. Container Security
Security Options
All containers should include these security options:Resource Limits
Prevent resource exhaustion with deploy limits:Non-Root Users
Containers should run as non-root users:Image Security
- Use specific image tags, not
latest - Prefer minimal base images (Alpine)
- Regularly update images:
docker-compose pull && docker-compose up -d - Scan images:
docker scan <image>
3. Authentication
Current State (TASKSET 2)
Individual service authentication:- Jellyfin: Built-in user accounts
- n8n: Basic auth via environment variables
- Traefik Dashboard: IP whitelist (LAN only)
- Samba: Unix user authentication
Future State (TASKSET 4+)
Centralized SSO with Authelia:- Single sign-on for all web services
- 2FA/MFA support
- LDAP integration for user management
Traefik Basic Auth
For services without built-in auth, use Traefik middleware:4. Secrets Management
File-Based Secrets
Secrets are stored in.secrets file:
Docker Secrets (Alternative)
For swarm mode or enhanced security:Secret Rotation
- Generate new secret
- Update
.secretsfile - Restart affected service
- Verify functionality
- Remove old secret from any backups
What NOT to Do
- Store secrets in
.env(may be logged) - Commit secrets to git
- Use default passwords
- Share secrets between services
5. TLS/Encryption
Certificate Management
Traefik handles TLS with Let’s Encrypt:Self-Signed Certificates (Development)
For local development without public DNS:TLS Best Practices
- Minimum TLS 1.2 (configured in Traefik)
- Strong cipher suites
- HSTS headers enabled
- Certificate pinning for mobile apps
6. Security Hardening Checklist
Initial Setup
- Run
./security/init-security.sh --fix - Configure
.secretsfile - Apply firewall rules
- Generate/obtain TLS certificates
- Set strong passwords for all services
Ongoing
- Weekly:
docker-compose pullto update images - Monthly: Review access logs
- Quarterly: Rotate secrets
- As needed: Security patches
Audit
7. Incident Response
If Compromised
- Isolate:
docker-compose down - Preserve: Copy logs before wiping
- Investigate: Check access logs, container logs
- Remediate: Identify entry point, patch vulnerability
- Recover: Restore from clean backup
- Rotate: All secrets, certificates, passwords
Log Locations
Emergency Contacts
Configure in.secrets:
8. Compliance Notes
Home Use
For personal/home use, this security configuration provides:- Protection from casual attacks
- Network isolation between services
- Basic access logging
- Encrypted external access
NOT Suitable For
- Healthcare (HIPAA)
- Payment processing (PCI-DSS)
- Enterprise production
- Multi-tenant environments
Related Documentation
firewall-rules.sh- Firewall configuration scriptinit-security.sh- Security initialization script.secrets.example- Secrets template../traefik/dynamic.yml- Security middleware configuration