Config Server
The x-fidelity config server provides centralized configuration management and real-time updates for your rules and archetypes.
Overview
The config server:
- Serves archetype configurations
- Distributes rules
- Manages exemptions
- Collects telemetry
- Handles GitHub webhooks
Server Setup
Using Docker
services:
x-fidelity-server:
build: .
ports:
- 8888:8888
volumes:
- ./config:/usr/src/app/config
environment:
- NODE_ENV=production
- XFI_LISTEN_PORT=8888
- CERT_PATH=/usr/src/app/certs
- XFI_SHARED_SECRET=your_secret_here
Manual Setup
xfidelity --mode server --port 8888
API Endpoints
Archetypes
GET /archetypes/:archetype
: Get archetype configurationGET /archetypes/:archetype/rules
: Get rules for archetypeGET /archetypes/:archetype/rules/:rule
: Get specific ruleGET /archetypes/:archetype/exemptions
: Get exemptions
Telemetry
POST /telemetry
: Submit telemetry data
Cache Management
POST /clearcache
: Clear server cacheGET /viewcache
: View cache contents
GitHub Webhooks
POST /github-config-update
: Update config from GitHubPOST /github-pull-request-check
: Check pull requests
Security Features
Authentication
Uses shared secret authentication:
export XFI_SHARED_SECRET=your_secret_here
HTTPS/TLS
Supports HTTPS with:
- Self-signed certificates
- Custom certificates
- Certificate path configuration
Rate Limiting
Configurable rate limiting:
- Default: 10,000 requests per minute
- Customizable window and limit
- IP-based tracking
Caching
- In-memory caching
- Configurable TTL
- Cache invalidation on updates
- View cache contents
Environment Variables
XFI_LISTEN_PORT
: Server portCERT_PATH
: SSL certificate pathXFI_SHARED_SECRET
: Authentication secretGITHUB_WEBHOOK_SECRET
: GitHub webhook secretNODE_TLS_REJECT_UNAUTHORIZED
: Allow self-signed certs
Best Practices
-
Security:
- Use HTTPS in production
- Set strong secrets
- Enable authentication
- Configure rate limits
-
Performance:
- Enable caching
- Set appropriate TTL
- Monitor server load
- Scale as needed
-
Monitoring:
- Collect telemetry
- Monitor errors
- Track usage
- Set up alerts
-
Maintenance:
- Regular updates
- Backup configurations
- Monitor disk space
- Review logs
Next Steps
- Set up Docker Deployment
- Configure GitHub Webhooks
- Implement Telemetry