A high-performance HTTP/HTTPS reverse proxy server built with Rust and Pingora.
- HTTP/HTTPS reverse proxy with TLS support
- Dynamic upstream server configuration
- Load balancing with health checks
- Configurable TLS for both client and upstream connections
- YAML-based configuration
- Built-in caching support
- HTTP/1.1 and HTTP/2 support
# Clone the repository
git clone https://github.com/wty92911/simple_proxy.git
cd simple_proxy
# Build the project
cargo build --release
The proxy is configured using a YAML file. Here's an example configuration:
global:
port: 3000
tls:
cert: ./certs/proxy.crt
key: ./certs/proxy.key
ca: ./certs/ca.crt
servers:
- server_name: ["example.com", "www.example.com"]
upstream: "backend_servers"
tls: true
upstreams:
- name: "backend_servers"
servers:
- "backend1:8080"
- "backend2:8080"
-
global
: Global proxy settingsport
: Port to listen ontls
: TLS configuration (optional)cert
: Path to certificate filekey
: Path to private key fileca
: Path to CA certificate file (optional)
-
servers
: List of server configurationsserver_name
: List of hostnames to matchupstream
: Name of the upstream server grouptls
: Whether to use TLS for upstream connections
-
upstreams
: List of upstream server groupsname
: Unique name for the upstream groupservers
: List of backend server addresses
# Run with default configuration
cargo run -- --config ./fixtures/sample.yml
# Run with custom configuration
cargo run -- --config /path/to/your/config.yml
The repository includes an example backend server that can be used for testing:
# Run the example server
cargo run --example server -- --port 3001 --tls --cert ./certs/backend.crt --key ./certs/backend.key
- Rust 1.70 or later
- OpenSSL development libraries
# Build in debug mode
cargo build
# Build in release mode
cargo build --release
# Run tests
cargo test
src/
├── conf/ # Configuration handling
├── proxy/ # Proxy implementation
│ ├── route.rs # Routing logic
│ └── utils.rs # Utility functions
└── main.rs # Application entry point
MIT License - see LICENSE file for details
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request