A secure, Rust-based Debian mirror redirector (aptg) with verification, caching, and policy enforcement.
- Secure Reverse Proxy: Fetches, verifies, and caches Debian packages
- GPG Verification: Verifies Debian package signatures using official keys
- Hash Validation: Validates package integrity using SHA256 hashes
- Smart Caching: Different TTLs for different file types
- Policy Engine: Access control based on suites, components, and architectures
- Audit Logging: Complete audit trail of all requests and actions
- APT Compatible: Works seamlessly with APT package manager
APT Client
|
v
Rust aptg
├── GPG Verification
├── Hash Validation (SHA256)
├── Cache (FS / Object storage)
├── Policy Engine
└── Audit Logs
|
v
Upstream Debian Mirror
-
Build and run:
cargo run
-
Configure APT:
echo "deb https://localhost:8080/debian bookworm main" | sudo tee /etc/apt/sources.list.d/mirror.list
-
Update package lists:
sudo apt update
Edit config.toml to customize:
- Server settings: Host, port
- Upstream: Debian mirror URL and timeout
- Cache: TTL values for different file types
- Policy: Allowed/denied suites, components, architectures
- Verification: GPG keyring path and verification settings
- Audit: Logging configuration
- Verifies
InReleasefiles - Verifies
Release+Release.gpgpairs - Uses official Debian archive keys
- Validates SHA256 hashes from Release files
- Ensures package integrity
- Prevents tampering
- Suite restrictions (bookworm, bullseye, etc.)
- Component filtering (main, contrib, non-free)
- Architecture controls (amd64, arm64, etc.)
- Package blacklisting
- Request logging with timestamps
- Cache hit/miss tracking
- Fetch success/failure records
- Policy violation alerts
| File Type | TTL | Description |
|---|---|---|
InRelease, Release, Release.gpg |
6 hours | Metadata files |
Packages*, Sources* |
12 hours | Package indices |
*.deb |
1 year | Package files (immutable) |
[policy.allow]
suites = ["bookworm"][policy.allow]
components = ["main", "contrib"][policy.deny]
architectures = ["i386", "armhf"]The service provides comprehensive logging:
# View audit logs
tail -f /var/log/aptg.log
# Monitor cache hits
grep "Cache hit" /var/log/aptg.log
# Check policy violations
grep "Policy violation" /var/log/aptg.log[Unit]
Description=aptg - Debian Mirror Redirector
After=network.target
[Service]
Type=simple
User=mirror
WorkingDirectory=/opt/aptg
ExecStart=/opt/aptg/target/release/aptg
Restart=always
[Install]
WantedBy=multi-user.targetserver {
listen 443 ssl;
server_name mirror.example.com;
location /debian/ {
proxy_pass http://localhost:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}- Key Management: Keep Debian archive keys secure
- Network Isolation: Run in isolated network segment
- Resource Limits: Set appropriate memory and CPU limits
- Access Control: Use firewall rules to restrict access
- Regular Updates: Keep the service and keys updated
cargo build --releasecargo testcargo run --features gpg-verifydocker build -t aptg .docker-compose up -dThis project uses GitHub Actions for Continuous Integration:
- Check: Validates that the code compiles.
- Test: Runs the unit test suite.
- Format: Ensures code style consistency.
- Clippy: Performs static analysis to catch common mistakes.
- Docker: Validates the Docker build on pushes to
main.
To create a new release with cross-platform binaries:
- Update version in
Cargo.toml. - Create and push a new tag:
git tag v0.1.0 git push origin v0.1.0
The Release workflow will automatically build binaries for Linux (amd64, arm64) and macOS (Intel, Apple Silicon) and attach them to a new GitHub Release.
This project is dual-licensed under the MIT and Apache 2.0 licenses.
Users can choose either license based on their requirements.
Contributions are welcome! Please read our CONTRIBUTING.md and Code of Conduct before submitting a Pull Request.
To report a security vulnerability, please see our Security Policy.
For issues and questions:
- Open a Bug Report or Feature Request
- Create an issue on GitHub
- Check the audit logs for troubleshooting
- Review the configuration documentation