Skip to content

VedoxDev/rate-limit-proxy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rate Limit Proxy

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.

🎯 What is this?

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.

⚠️ Important Note

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.

✨ What it does

  • 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

🚀 Quick Start

Using Docker

# 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

Using Go directly

# 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

⚙️ Configuration

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

🏗️ Simple Architecture

Client Request → Rate Limit Proxy → Backend Service
                (Basic Rate Limiting)
                (Simple Request Forwarding)

Uses a basic sliding window approach - nothing fancy, just functional.

📁 Project Structure

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

🔮 Future Enhancements

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

🛠️ Built With

  • Go 1.24.5 - For its excellent HTTP tooling and concurrency primitives
  • Standard library only - No external dependencies
  • Docker - For easy deployment and containerization

📝 License

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.

About

A simple HTTP proxy with rate limiting built in Go. Transparently protects your APIs without backend modifications.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors