pub async fn handle_request<C: ConfigProvider>(
req: Request<Incoming>,
forward_host: String,
forward_port: u16,
limiter: RateLimiter,
config: Arc<C>,
http_client: Client,
) -> Result<Response<Full<Bytes>>, Infallible>Expand description
Handles an incoming HTTP request through the proxy pipeline.
This is the main entry point for request processing. It performs:
- Client IP extraction and validation from proxy headers
- IP blocking checks
- URL pattern blocking (e.g.,
.php,.envfiles) - HTTP method blocking (e.g.,
PUT,DELETE) - Rate limiting per client IP
- Request forwarding to the upstream service
§Arguments
req- The incoming HTTP requestforward_host- The upstream host to forward requests toforward_port- The upstream port to forward requests tolimiter- The shared rate limiter instanceconfig- Configuration provider for all settingshttp_client- HTTP client for forwarding requests (with connection pooling)
§Returns
Always returns Ok with either:
- A successful proxied response from upstream
- An error response (403, 404, 405, 429, 502, etc.)
§Security
In strict mode (when proxy allowlist is configured), requests without valid proxy headers are rejected with 403 Forbidden.