A robust, high-performance DNS proxy server written in Go, featuring Redis-based caching, multi-upstream support (IPv4/IPv6), and hot-reloading for development.
.
├── main.go # Main entry point
├── internal/
│ ├── cache/ # Redis caching logic
│ ├── config/ # Configuration handling
│ └── proxy/ # DNS proxy core logic
├── Dockerfile # Production Dockerfile
├── Dockerfile.dev # Development Dockerfile
└── docker-compose.yml # Orchestration
- Redis Caching: Automatically caches DNS responses based on the upstream TTL to reduce latency and load.
- High Performance: Optimized Redis connection pooling and server configuration for extreme throughput.
- Multi-Upstream Support: Dynamically load up to 10 upstream DNS servers via environment variables. Supports both IPv4 and IPv6.
- Fault Tolerance: Automatically retries across all configured upstream servers if one fails.
- Hot Reloading: Developer-friendly setup using
airfor instant feedback upon code changes. - Dockerized: Ready for production and development environments using Docker and Docker Compose.
- Request Monitoring: Real-time logging of client requests and cache hits.
- Docker and Docker Compose
- Go 1.25+ (if running locally)
The application is configured primarily through environment variables or a .env file.
| Variable | Description | Default |
|---|---|---|
REDIS_ADDR |
Address of the Redis server | localhost:6379 |
DNS_SERVER_0 ... DNS_SERVER_9 |
Upstream DNS servers (e.g., 8.8.8.8, 1.1.1.1) |
- |
Note: If no upstream servers are configured, the proxy falls back to Cloudflare DNS (1.1.1.1 and 2606:4700:4700::1111).
This mode mounts your local directory into the container and uses air to recompile the app whenever you save a file.
docker-compose -f docker-compose.dev.yml up --buildOptimized for stability and performance.
docker-compose up -d --buildThe DNS proxy will listen on port 53/udp.
This project uses GitHub Actions to automatically build and push Docker images to GitHub Packages (GHCR) when a new release is published.
- When you create and publish a new Release on GitHub, the
Docker Publishworkflow is triggered. - It builds the Docker image and tags it with the release version (e.g.,
v1.2.3), major/minor versions (1.2), and the commit SHA. - The image is pushed to
ghcr.io/${{ github.repository }}.
To pull the image:
docker pull ghcr.io/<your-username>/dns-proxy:latestThe Go client is configured with:
PoolSize: 100: High concurrency support.MinIdleConns: 10: Keeps persistent connections alive.PoolTimeout: 30s: Prevents blocking under heavy load.
The Redis instance is tuned for caching:
- Disabled RDB/AOF persistence to maximize I/O throughput.
- Optimized TCP keepalive for long-lived connections.
MIT License