A high-performance HTTP/HTTPS proxy server written in Go with Basic Auth authentication and production-ready Docker deployment
A lightweight, secure, and easy-to-deploy proxy server perfect for development, testing, and production environments.
| Feature | Description |
|---|---|
| 🌐 HTTP/HTTPS Proxy | Full support for both HTTP and HTTPS protocols |
| 🔐 Basic Auth | Secure username/password authentication for all requests |
| 🔗 CONNECT Method | Native support for HTTPS tunneling |
| ⚙️ Environment Config | Simple configuration via environment variables |
| 🐳 Docker Ready | Multi-stage Docker build for optimized images |
| 💚 Health Check | Built-in health monitoring endpoint |
| 📝 Request Logging | Detailed logging for monitoring and debugging |
| 👤 Non-root User | Security-focused container running as non-root |
# Clone or download project
cd go-proxy-server
# Install dependencies
go mod tidy
# Set environment variables (optional)
export PROXY_USERNAME=admin
export PROXY_PASSWORD=mypassword
export PROXY_PORT=8080
# Run application
go run main.go# Build binary
go build -o proxy-server
# Run binary
./proxy-server# Build Docker image
docker build -t go-proxy-server .
# Run container with default credentials
docker run -d \
--name proxy-server \
-p 8080:8080 \
go-proxy-server
# Run container with custom credentials
docker run -d \
--name proxy-server \
-p 8080:8080 \
-e PROXY_USERNAME=myuser \
-e PROXY_PASSWORD=mypassword \
go-proxy-server# Copy environment file
cp .env.example .env
# Edit .env file with desired credentials
nano .env
# Start with docker-compose
docker-compose up -d
# View logs
docker-compose logs -f
# Stop
docker-compose downThe application uses environment variables for configuration:
| Variable | Default | Description |
|---|---|---|
PROXY_USERNAME |
admin |
Username for proxy authentication |
PROXY_PASSWORD |
password123 |
Password for proxy authentication |
PROXY_PORT |
8080 |
Proxy server port |
| Setting | Value |
|---|---|
| Proxy Type | HTTP |
| Server | localhost (or your server IP) |
| Port | 8080 (or your configured port) |
| Username | As per PROXY_USERNAME |
| Password | As per PROXY_PASSWORD |
# Test HTTP request
curl -v \
--proxy http://admin:mypassword@localhost:8080 \
http://httpbin.org/ip
# Test HTTPS request
curl -v \
--proxy http://admin:mypassword@localhost:8080 \
https://httpbin.org/ip# Set proxy environment
export http_proxy=http://admin:mypassword@localhost:8080
export https_proxy=http://admin:mypassword@localhost:8080
# Test request
wget http://httpbin.org/ipThe application has a built-in health check that can be used for monitoring:
# Check health (for monitoring only, not for proxy)
curl http://localhost:8080The application will display logs for each request:
2024/01/01 12:00:00 127.0.0.1:12345 GET http://example.com
2024/01/01 12:00:01 127.0.0.1:12346 CONNECT example.com:443| Security Feature | Description |
|---|---|
| 🔐 Basic Auth | Authentication required for all requests |
| 👤 Non-root User | Container runs as non-root user |
| 🏔️ Alpine Linux | Minimal, secure base image |
| 📦 No Extra Packages | Only necessary dependencies installed |
Solution: Make sure the username and password used match the server configuration.
Solution: The application has a 30-second timeout for each request. For longer requests, adjust the timeout in the code.
Solution: Change the port in the PROXY_PORT environment variable or use a different port when running the container.
This project is equipped with GitHub Actions workflows for automation:
- Trigger: Push to
main/develop, Pull Request, or Tag - Process:
- ✅ Test and build application
- ✅ Security scan with staticcheck
- ✅ Build multi-platform Docker images
- ✅ Push to GitHub Container Registry
- ✅ Vulnerability scan with Trivy
- Trigger: Push tag with format
v*(example:v1.0.0) - Process:
- ✅ Build binary for multiple platforms (Linux, macOS, Windows)
- ✅ Create checksums
- ✅ Build and push Docker images
- ✅ Create GitHub release with binaries
- ✅ Generate automatic release notes
- Trigger: Daily schedule or manual
- Process:
- ✅ Dependency scanning with Gosec
- ✅ Container vulnerability scanning
- ✅ Upload results to GitHub Security tab
- Trigger: Push tag
v*or manual - Process:
- ✅ Build and push to Docker Hub
- ✅ Update description automatically
- Required Secrets:
# For Docker Hub (optional)
DOCKERHUB_USERNAME=your-dockerhub-username
DOCKERHUB_TOKEN=your-dockerhub-access-token- Branch Protection Rules (Recommended):
- Require pull request reviews
- Require status checks (CI tests)
- Require branches to be up to date
# Patch release (1.0.0 -> 1.0.1)
./scripts/release.sh patch
# Minor release (1.0.1 -> 1.1.0)
./scripts/release.sh minor
# Major release (1.1.0 -> 2.0.0)
./scripts/release.sh major# Create and push tag
git tag -a v1.0.0 -m "Release v1.0.0"
git push origin v1.0.0
# GitHub Actions will automatically:
# - Build application for multiple platforms
# - Create Docker images
# - Create GitHub release
# - Generate release notes# Pull latest
docker pull ghcr.io/your-username/go-proxy-server:latest
# Pull specific version
docker pull ghcr.io/your-username/go-proxy-server:v1.0.0# Pull latest
docker pull your-username/go-proxy-server:latest
# Pull specific version
docker pull your-username/go-proxy-server:v1.0.0# Setup development environment
./scripts/setup-dev.sh
# Install git hooks, dependencies, and toolsgo-proxy-server/
├── .github/
│ ├── workflows/ # GitHub Actions workflows
│ │ ├── ci-cd.yml # Main CI/CD pipeline
│ │ ├── release.yml # Release automation
│ │ ├── security.yml # Security scanning
│ │ └── dockerhub.yml # Docker Hub publishing
│ ├── ISSUE_TEMPLATE/ # Issue templates
│ ├── dependabot.yml # Dependency updates
│ └── pull_request_template.md
├── scripts/
│ ├── release.sh # Release automation script
│ └── setup-dev.sh # Development setup
├── main.go # Main application
├── go.mod # Go modules
├── Dockerfile # Docker configuration
├── docker-compose.yml # Docker Compose
├── .env.example # Environment example
├── .gitignore # Git ignore
└── README.md # Documentation
./scripts/setup-dev.shgit checkout -b feature/your-feature# Run locally
go run main.go
# Or with Docker
docker-compose up --build# Run tests
go test ./...
# Run linting
staticcheck ./...
golangci-lint rungit add .
git commit -m "feat: add your feature"
git push origin feature/your-feature- GitHub will automatically run CI checks
- Review and merge to main
# After merge to main
git checkout main
git pull origin main
./scripts/release.sh patch # or minor/major| Feature | Description |
|---|---|
| 🤖 Dependabot | Automatically updates dependencies every Monday |
| 🔒 Security Scans | Run daily for vulnerability detection |
| 💚 Health Checks | Built-in health check in container |
| 📝 Logging | Request logging for monitoring |
- Edit
main.goto add new logic - Add tests if needed
- Update documentation in
README.md - Create Pull Request with clear description
This project is licensed under the MIT License - see the LICENSE file for details.
Made with ❤️ using Go