|
1 | | -# rust-reverse-proxy |
2 | | -a lightweight and high performance HTTP and TCP reverse proxy written in Rust. |
| 1 | +# Rust Reverse Proxy |
3 | 2 |
|
4 | | -Prioritizing security and memory concurrency. Ultra fast performance. currently trying to update to improve. I want it to be fast and capable of serving a lot of users |
| 3 | +[](https://github.com/HueCodes/rust-reverse-proxy/actions/workflows/rust.yml) |
| 4 | +[](https://crates.io/crates/rust-reverse-proxy) |
5 | 5 |
|
6 | | -currently adding multiple warp based endpoints |
| 6 | +A lightweight and fast HTTP reverse proxy written in Rust. This project leverages the [Warp](https://github.com/seanmonstar/warp) framework for efficient request handling and routing, providing a simple yet powerful solution for proxying HTTP traffic. |
| 7 | + |
| 8 | +## Features |
| 9 | + |
| 10 | +- **High Performance**: Built with Rust's zero-cost abstractions and async runtime for low-latency proxying. |
| 11 | +- **Flexible Routing**: Supports multiple upstream backends with easy configuration. |
| 12 | +- **TLS Support**: Optional TLS termination and forwarding (planned). |
| 13 | +- **Logging and Metrics**: Built-in structured logging and basic metrics (in development). |
| 14 | +- **Configurable**: YAML or TOML-based configuration for backends, filters, and middleware. |
| 15 | + |
| 16 | +## Quick Start |
| 17 | + |
| 18 | +### Prerequisites |
| 19 | + |
| 20 | +- Rust 1.70+ (stable) |
| 21 | +- Cargo |
| 22 | + |
| 23 | +### Installation |
| 24 | + |
| 25 | +Clone the repository and build with Cargo: |
| 26 | + |
| 27 | +```bash |
| 28 | +git clone https://github.com/HueCodes/rust-reverse-proxy.git |
| 29 | +cd rust-reverse-proxy |
| 30 | +cargo build --release |
| 31 | +``` |
| 32 | + |
| 33 | +### Running the Proxy |
| 34 | + |
| 35 | +Create a basic configuration file `config.yaml`: |
| 36 | + |
| 37 | +```yaml |
| 38 | +backends: |
| 39 | + - name: "api" |
| 40 | + host: "http://localhost:8080" |
| 41 | + path_prefix: "/api" |
| 42 | + - name: "web" |
| 43 | + host: "http://localhost:3000" |
| 44 | + path_prefix: "/" |
| 45 | + |
| 46 | +port: 80 |
| 47 | +``` |
| 48 | +
|
| 49 | +Start the proxy: |
| 50 | +
|
| 51 | +```bash |
| 52 | +cargo run -- --config config.yaml |
| 53 | +``` |
| 54 | + |
| 55 | +Or with the release binary: |
| 56 | + |
| 57 | +```bash |
| 58 | +./target/release/rust-reverse-proxy --config config.yaml |
| 59 | +``` |
| 60 | + |
| 61 | +The proxy will listen on port 80 and forward requests to the configured backends based on path prefixes. |
| 62 | + |
| 63 | +## Configuration |
| 64 | + |
| 65 | +The proxy uses a YAML configuration file. Key sections: |
| 66 | + |
| 67 | +- `backends`: List of upstream services with `name`, `host`, `path_prefix`, and optional `strip_prefix`. |
| 68 | +- `port`: Listening port (default: 80). |
| 69 | +- `log_level`: Logging verbosity (e.g., "info", "debug"). |
| 70 | +- `tls`: TLS configuration (cert and key paths, enabled by default if provided). |
| 71 | + |
| 72 | +For full options, see `config.yaml.example` (to be added). |
| 73 | + |
| 74 | +## Usage Examples |
| 75 | + |
| 76 | +### Basic Proxying |
| 77 | + |
| 78 | +Proxy all `/api/*` requests to `http://backend:8080`: |
| 79 | + |
| 80 | +```yaml |
| 81 | +backends: |
| 82 | + - name: "backend" |
| 83 | + host: "http://backend:8080" |
| 84 | + path_prefix: "/api" |
| 85 | +``` |
| 86 | +
|
| 87 | +### Load Balancing |
| 88 | +
|
| 89 | +Support for round-robin load balancing across multiple hosts (planned feature): |
| 90 | +
|
| 91 | +```yaml |
| 92 | +backends: |
| 93 | + - name: "api-cluster" |
| 94 | + hosts: |
| 95 | + - "http://backend1:8080" |
| 96 | + - "http://backend2:8080" |
| 97 | + path_prefix: "/api" |
| 98 | + strategy: "round_robin" |
| 99 | +``` |
| 100 | +
|
| 101 | +### Middleware |
| 102 | +
|
| 103 | +Add rate limiting or authentication middleware via configuration (in development). |
| 104 | +
|
| 105 | +## Development |
| 106 | +
|
| 107 | +This project is actively under development. Current focus: |
| 108 | +
|
| 109 | +- Implementing core proxy logic with Warp. |
| 110 | +- Adding configuration parsing. |
| 111 | +- TLS integration with Rustls. |
| 112 | +
|
| 113 | +### Building and Testing |
| 114 | +
|
| 115 | +```bash |
| 116 | +# Run tests |
| 117 | +cargo test |
| 118 | + |
| 119 | +# Run with clippy |
| 120 | +cargo clippy -- -D warnings |
| 121 | + |
| 122 | +# Format code |
| 123 | +cargo fmt |
| 124 | +``` |
| 125 | + |
| 126 | +### Dependencies |
| 127 | + |
| 128 | +See `Cargo.toml` for details. Key crates: |
| 129 | + |
| 130 | +- `warp`: Web server framework. |
| 131 | +- `tokio`: Async runtime. |
| 132 | +- `serde`: Configuration serialization. |
| 133 | +- `tracing`: Logging. |
| 134 | + |
| 135 | +## Contributing |
| 136 | + |
| 137 | +Contributions are welcome! Please: |
| 138 | + |
| 139 | +1. Fork the repository. |
| 140 | +2. Create a feature branch (`git checkout -b feature/my-feature`). |
| 141 | +3. Commit changes (`git commit -am 'Add my feature'`). |
| 142 | +4. Push to the branch (`git push origin feature/my-feature`). |
| 143 | +5. Open a Pull Request. |
| 144 | + |
| 145 | +See [CONTRIBUTING.md](CONTRIBUTING.md) for more details (to be created). |
| 146 | + |
| 147 | +## License |
| 148 | + |
| 149 | +This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. |
| 150 | + |
| 151 | +## Acknowledgments |
| 152 | + |
| 153 | +- Inspired by various Rust web projects and the need for a simple, performant proxy. |
| 154 | +- Thanks to the Warp and Tokio teams for excellent crates. |
| 155 | + |
| 156 | +--- |
| 157 | + |
| 158 | +*Project started in 2025. More features coming soon!* |
0 commit comments