A Kubernetes-native solution for mirroring HTTP directory listings and serving them via a web server.
HTTP Mirror uses a two-component approach following Kubernetes best practices:
- Web Server (Deployment): Always-running Go web server that serves mirrored files with custom directory listings
- Updater (CronJob): Scheduled Go binary that downloads/updates files from configured HTTP directory listings
Both components share data via a Kubernetes PersistentVolume and are configured through a shared ConfigMap.
β
Smart mirroring - HTTP HEAD requests to check file changes before download
β
Built-in file server - Custom directory listings with search and filtering
β
Kubernetes-native - CronJob scheduling with timezone support
β
Rate limiting - Configurable download speeds to be respectful
β
Multi-target support - Mirror multiple sites with individual configurations
β
Change detection - Only download files that have actually changed
β
Resumable downloads - Continue interrupted downloads
β
Health checks - Kubernetes-ready liveness and readiness probes
β
Monitoring - Prometheus metrics and ServiceMonitor support
# Add the Helm repository
helm repo add jhofer-cloud https://charts.jhofer.org
helm repo update
# Install with basic configuration
helm install my-mirror jhofer-cloud/http-mirror \
--set targets[0].name=example \
--set targets[0].url=http://example.com/files/ \
--set ingress.enabled=true \
--set ingress.hosts[0].host=mirror.example.com# Create a config file
cat > config.json << EOF
{
"targets": [
{
"name": "example",
"url": "http://example.com/files/"
}
]
}
EOF
# Run updater once
docker run --rm -v $(pwd)/data:/data -v $(pwd)/config.json:/config/config.json \
ghcr.io/jhofer-cloud/http-mirror-updater:latest
# Start web server
docker run -d -p 8080:8080 -v $(pwd)/data:/data -v $(pwd)/config.json:/config/config.json \
ghcr.io/jhofer-cloud/http-mirror-server:latestSee: https://github.com/JHOFER-Cloud/helm-charts/tree/main/charts/http-mirror
- Go 1.21+
- Docker
- Kubernetes cluster (for testing)
# Clone the repository
git clone https://github.com/jhofer-cloud/http-mirror.git
cd http-mirror
# Download dependencies
go mod download
# Build binaries
go build -o bin/server ./cmd/server
go build -o bin/updater ./cmd/updater
# Run tests
go test -v ./...# Build server image
docker build -f Dockerfile.server -t http-mirror-server .
# Build updater image
docker build -f Dockerfile.updater -t http-mirror-updater .http-mirror/
βββ cmd/
β βββ server/ # Web server binary
β βββ updater/ # Mirror updater binary
βββ pkg/
β βββ config/ # Shared configuration
β βββ http/ # HTTP client with rate limiting
β βββ files/ # File handler with directory listings
β βββ mirror/ # Core mirroring logic
βββ Dockerfile.server # Server container image
βββ Dockerfile.updater # Updater container image
βββ .github/workflows/ # CI/CD pipelines
- Configuration: Targets are configured via ConfigMap or environment variables
- Scheduling: CronJob triggers the updater at configured times
- Smart Mirroring: Updater checks remote file timestamps/ETags before downloading
- File Storage: Files are stored in a shared PersistentVolume
- Web Serving: Always-running server serves files with auto-generated directory listings
- Monitoring: Health checks and optional Prometheus metrics
- Archive Preservation: Mirror important file repositories before they disappear
- Local Caching: Speed up access to frequently used files
- Offline Access: Make remote files available when internet is limited
- Compliance: Keep local copies of compliance-related downloads
- Development: Mirror dependency archives for air-gapped environments
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Run
go test ./...andgo vet ./... - Submit a pull request
- π Documentation
- π Issues
- π¬ Discussions