Salvo is an extremely simple and powerful Rust web backend framework. Only basic Rust knowledge is required to develop backend services.
salvo-proxy
Proxy middleware for Salvo
This crate provides proxy capabilities for the Salvo web framework, allowing you to forward requests to upstream servers. It's useful for creating API gateways, load balancers, and reverse proxies.
Features
- Support for HTTP and HTTPS proxying
- Multiple upstream server selection strategies
- WebSocket connection support
- Header manipulation
- Path and query rewriting
- Multiple HTTP client backends (Hyper, Reqwest)
Usage
This is an official crate, so you can enable it in Cargo.toml like this:
= { = "*", = ["proxy"] }
Path forwarding
The default path getter forwards the wildcard tail captured by routes such as
Router::with_path("api/{**rest}"). If the upstream is http://backend, the
gateway path /api/users is forwarded to http://backend/users. If the backend
also expects the /api prefix, configure the upstream with that base path:
http://backend/api.
Proxy normalizes literal . and .. path segments before forwarding. When
the proxy is used as an access-control boundary and the upstream may perform an
additional URL decode pass, enable strict path normalization to reject ambiguous
encoded path characters:
use *;
use Proxy;
let router = with_path.goal;
Strict path normalization rejects percent-encoded ., /, \, and %
characters in the proxied path tail, including cases such as %2e%2e,
%2f, %5c, and double-encoded forms that remain percent-encoded after
Salvo routing extracts the tail. Backends should still validate and normalize
their own routes and file paths; this option only prevents common proxy/backend
path interpretation mismatches.
☕ Donate
Salvo is an open source project. If you want to support Salvo, you can ☕ buy me a coffee here.
⚠️ License
Salvo is licensed under Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0).