https://github.com/andrearaponi/dito Skip to content Navigation Menu Toggle navigation Sign in * Product + GitHub Copilot Write better code with AI + Security Find and fix vulnerabilities + Actions Automate any workflow + Codespaces Instant dev environments + Issues Plan and track work + Code Review Manage code changes + Discussions Collaborate outside of code + Code Search Find more, search less Explore + All features + Documentation + GitHub Skills + Blog * Solutions By size + Enterprise + Teams + Startups By industry + Healthcare + Financial services + Manufacturing By use case + CI/CD & Automation + DevOps + DevSecOps * Resources Topics + AI + DevOps + Security + Software Development + View all Explore + Learning Pathways + White papers, Ebooks, Webinars + Customer Stories + Partners * Open Source + GitHub Sponsors Fund open source developers + The ReadME Project GitHub community articles Repositories + Topics + Trending + Collections * Enterprise + Enterprise platform AI-powered developer platform Available add-ons + Advanced Security Enterprise-grade security features + GitHub Copilot Enterprise-grade AI features + Premium Support Enterprise-grade 24/7 support * Pricing Search or jump to... Search code, repositories, users, issues, pull requests... Search [ ] Clear Search syntax tips Provide feedback We read every piece of feedback, and take your input very seriously. [ ] [ ] Include my email address so I can be contacted Cancel Submit feedback Saved searches Use saved searches to filter your results more quickly Name [ ] Query [ ] To see all available qualifiers, see our documentation. Cancel Create saved search Sign in Sign up Reseting focus You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert {{ message }} andrearaponi / dito Public * Notifications You must be signed in to change notification settings * Fork 3 * Star 124 an advanced Layer 7 reverse proxy server written in Go License MIT license 124 stars 3 forks Branches Tags Activity Star Notifications You must be signed in to change notification settings * Code * Issues 1 * Pull requests 0 * Actions * Projects 0 * Security * Insights Additional navigation options * Code * Issues * Pull requests * Actions * Projects * Security * Insights andrearaponi/dito This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository. main BranchesTags Go to file Code Folders and files Name Name Last commit message Last commit date Latest commit History 3 Commits app app bin bin client/redis client/redis cmd cmd config config handlers handlers logging logging middlewares middlewares transport transport writer writer LICENSE LICENSE Makefile Makefile README.md README.md dito.png dito.png go.mod go.mod go.sum go.sum View all files Repository files navigation * README * MIT license Dito Advanced Layer 7 Reverse Proxy Server [6874747073] [6874747073] [6874747073] [6874747073] Dito Logo Dito is an advanced Layer 7 reverse proxy server written in Go. It provides flexible middleware support, custom certificate handling for backend connections, dynamic configuration reloading, and distributed caching and rate limiting with Redis. Features * Layer 7 reverse proxy for handling HTTP requests * Dynamic configuration reloading (hot reload) * Middleware support (e.g., an example of authentication, rate limiting, caching) * Distributed rate limiting with Redis * Distributed caching with Redis * Custom TLS certificate management for backends (mTLS support) * Header manipulation (additional headers, excluded headers) * Logging support with detailed request and response logs Project Structure * cmd/: Entry point for the application. * app/: Core application logic. * client: Redis client for caching and rate limiting. * config/: Configuration-related utilities (loading, hot-reload). * handlers/: Core handlers for request routing and reverse proxy logic. * middlewares/: Custom middleware implementations (e.g., authentication, caching, rate limiting). * transport/: HTTP transport customization (including TLS management). * writer/: Custom HTTP response writers for capturing status codes. * logging/: Utilities for logging requests and responses. Installation Make sure you have Go installed (version 1.16 or later). 1. Clone the repository: git clone https://github.com/andrearaponi/dito.git cd dito 2. Build the application: go build -o dito ./cmd Usage You can run Dito by simply executing the binary. By default, it looks for config.yaml in the current working directory. ./dito Command-Line Options * -f : Specify a custom configuration file. Example: ./dito -f /path/to/custom-config.yaml Configuration The configuration is defined in a yaml file, which can be dynamically reloaded if the hot_reload option is enabled. Here's an example of a basic configuration: port: '8081' # The port on which the server listens hot_reload: true # Enable hot-reload of configuration logging: enabled: true # Enable or disable logging verbose: false # Enable verbose logging redis: enabled: true # Enable Redis for caching and rate limiting address: "localhost:6379" password: "yourpassword" db: 0 locations: - path: "^/api$" target_url: https://example.com replace_path: true additional_headers: X-Custom-Header: "my-value" il-molise: "non-esiste" excluded_headers: - Cookie middlewares: - auth - rate-limiter-redis - cache cache_config: enabled: true ttl: 60 # Cache time-to-live in seconds rate_limiting: enabled: true requests_per_second: 5 burst: 10 cert_file: "certs/client-cert.pem" key_file: "certs/client-key.pem" ca_file: "certs/ca-cert.pem" Middlewares Dito supports custom middlewares, which can be specified in the configuration. Currently available middleware includes: * auth: Adds authentication logic. * rate-limiter: Limits the number of requests per IP using an in-memory approach. * rate-limiter-redis: Limits the number of requests per IP using Redis for distributed management. * cache: Caches responses using Redis, improving performance for idempotent responses (e.g., GET). Redis Integration Rate Limiting Dito supports distributed rate limiting using Redis. The rate limiter can be configured per location with parameters like requests_per_second and burst to control the request flow. Caching The cache middleware uses Redis to store responses. It helps in reducing load on backends by caching responses for a configurable ttl (time-to-live). The cache can be invalidated based on request headers or specific conditions. Implementing a New Middleware To implement a new middleware, place your logic in the middlewares/ directory and reference it in the configuration. TLS/SSL Dito supports mTLS (mutual TLS) for secure connections to backends. You can specify: * cert_file: The client certificate. * key_file: The client private key. * ca_file: The certificate authority (CA) for verifying the backend. License This project is licensed under the MIT License. See the LICENSE file for details. About an advanced Layer 7 reverse proxy server written in Go Resources Readme License MIT license Activity Stars 124 stars Watchers 1 watching Forks 3 forks Report repository Releases No releases published Packages 0 No packages published Languages * Go 97.3% * Makefile 2.7% Footer (c) 2024 GitHub, Inc. Footer navigation * Terms * Privacy * Security * Status * Docs * Contact * Manage cookies * Do not share my personal information You can't perform that action at this time.