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