A simple HTTP proxy server with basic rate limiting, built in Go. While Go isn't my primary language, this worked as an exercise to explore Go's HTTP tooling and concurrency safety patterns.
I needed a rate limiter but didn't want to modify my backend code. This proxy sits in front of your application and handles rate limiting transparently, allowing you to protect your APIs without touching existing code. It's a functional solution that works for basic use cases.
This is a simple implementation that works for basic use cases. There are many more robust and feature-rich rate limiting solutions available for production environments.
- Basic per-IP rate limiting with configurable requests per second
- Simple HTTP proxying to a single backend
- Environment-based configuration
- Concurrent-safe using basic sync patterns
# Build the image
docker build -t rate-limit-proxy .
# Run with default settings
docker run -p 8080:8080 rate-limit-proxy
# Run with custom configuration
docker run -p 8080:8080 \
-e TARGET_URL=http://httpbin.org \
-e RATE_LIMIT=20 \
-e PORT=8080 \
rate-limit-proxy# Build the binary
go build -o proxy ./cmd/proxy
# Run with default settings
./proxy
# Run with custom configuration
TARGET_URL=http://httpbin.org RATE_LIMIT=20 PORT=8080 ./proxy| Environment Variable | Default | Description |
|---|---|---|
TARGET_URL |
http://httpbin.org |
Backend URL to proxy requests to |
RATE_LIMIT |
10 |
Maximum requests per second per IP |
PORT |
8080 |
Port to listen on |
Client Request → Rate Limit Proxy → Backend Service
(Basic Rate Limiting)
(Simple Request Forwarding)
Uses a basic sliding window approach - nothing fancy, just functional.
rate-limit-proxy/
├── cmd/proxy/ # Application entry point
│ └── main.go # Main function and configuration
├── internal/proxy/ # Core proxy logic
│ ├── handler.go # HTTP request handling
│ └── limiter.go # Basic rate limiting
├── Dockerfile # Container build
└── go.mod # Go module definition
This project was intentionally kept simple to validate the concept. Future versions could include:
- Multi-endpoint rate limits - Per-path or per-method limits
- Distributed rate limiting - Shared counters via Redis
- Configurable rules - YAML/JSON config for limits per endpoint
- Monitoring - Prometheus metrics for requests dropped
- Authentication - JWT-based rate limiting
- Whitelist/Blacklist - IP-based access control
- Go 1.24.5 - For its excellent HTTP tooling and concurrency primitives
- Standard library only - No external dependencies
- Docker - For easy deployment and containerization
This project is open source and available under the MIT License.
Note: This proxy is designed for small to medium-scale deployments and development environments. For production use with high traffic or distributed systems, consider using robust solutions like Redis-based rate limiting.