pub struct ReverseProxyHandler {Show 21 fields
failed_backends: Arc<RwLock<TtlCache<UpstreamInner, u64>>>,
load_balancer_algorithm: Arc<LoadBalancerAlgorithmInner>,
proxy_to: Arc<Vec<(Upstream, Option<usize>, Option<Duration>)>>,
health_check_max_fails: u64,
selected_backends_metrics: Option<Vec<UpstreamInner>>,
unhealthy_backends_metrics: Option<Vec<UpstreamInner>>,
connection_reused: bool,
enable_health_check: bool,
disable_certificate_verification: bool,
proxy_intercept_errors: bool,
retry_connection: bool,
proxy_http2_only: bool,
proxy_http2: bool,
proxy_keepalive: bool,
proxy_header: Option<ProxyHeader>,
headers_to_add: Arc<Vec<(HeaderName, String)>>,
headers_to_replace: Arc<Vec<(HeaderName, String)>>,
headers_to_remove: Arc<Vec<HeaderName>>,
rewrite_host: bool,
connections: Arc<Pool<(UpstreamInner, Option<IpAddr>), SendRequestWrapper>>,
unix_connections: Arc<Pool<(UpstreamInner, Option<IpAddr>), SendRequestWrapper>>,
}Expand description
Handlers for the reverse proxy module
Fields§
§failed_backends: Arc<RwLock<TtlCache<UpstreamInner, u64>>>§load_balancer_algorithm: Arc<LoadBalancerAlgorithmInner>§proxy_to: Arc<Vec<(Upstream, Option<usize>, Option<Duration>)>>§health_check_max_fails: u64§selected_backends_metrics: Option<Vec<UpstreamInner>>§unhealthy_backends_metrics: Option<Vec<UpstreamInner>>§connection_reused: bool§enable_health_check: bool§disable_certificate_verification: bool§proxy_intercept_errors: bool§retry_connection: bool§proxy_http2_only: bool§proxy_http2: bool§proxy_keepalive: bool§proxy_header: Option<ProxyHeader>§headers_to_add: Arc<Vec<(HeaderName, String)>>§headers_to_replace: Arc<Vec<(HeaderName, String)>>§headers_to_remove: Arc<Vec<HeaderName>>§rewrite_host: bool§connections: Arc<Pool<(UpstreamInner, Option<IpAddr>), SendRequestWrapper>>§unix_connections: Arc<Pool<(UpstreamInner, Option<IpAddr>), SendRequestWrapper>>Implementations§
Source§impl ReverseProxyHandler
impl ReverseProxyHandler
fn status_response(status_code: StatusCode) -> ResponseData
async fn mark_backend_failure(&mut self, upstream: &UpstreamInner)
async fn retry_or_respond( &self, error_logger: &ErrorLogger, err: &dyn Display, retry_connection: bool, has_more_backends: bool, status_code: StatusCode, log_prefix: &str, ) -> Option<ResponseData>
fn io_error_status(err: &Error) -> (StatusCode, &'static str)
Trait Implementations§
Source§impl ModuleHandlers for ReverseProxyHandler
impl ModuleHandlers for ReverseProxyHandler
Source§fn request_handler<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 mut self,
request: Request<BoxBody<Bytes, Error>>,
config: &'life1 ServerConfiguration,
socket_data: &'life2 SocketData,
error_logger: &'life3 ErrorLogger,
) -> Pin<Box<dyn Future<Output = Result<ResponseData, Box<dyn Error + Send + Sync>>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn request_handler<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 mut self,
request: Request<BoxBody<Bytes, Error>>,
config: &'life1 ServerConfiguration,
socket_data: &'life2 SocketData,
error_logger: &'life3 ErrorLogger,
) -> Pin<Box<dyn Future<Output = Result<ResponseData, Box<dyn Error + Send + Sync>>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Handles incoming HTTP requests and proxies them to the configured backend server(s)
This handler:
- Determines which backend server to proxy to (supports load balancing)
- Transforms the request by:
- Converting the URL to match the backend format
- Setting appropriate headers (Host, X-Forwarded-*)
- Establishes a connection to the backend (HTTP or HTTPS)
- Forwards the request and returns the response
The handler supports:
- Load balancing across multiple backends
- Connection pooling/reuse
- Health checking (marking failed backends)
- TLS/SSL for secure connections
- HTTP protocol upgrades (e.g., WebSockets)
Source§fn metric_data_before_handler<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 mut self,
_request: &'life1 Request<BoxBody<Bytes, Error>>,
_socket_data: &'life2 SocketData,
_metrics_sender: &'life3 MetricsMultiSender,
) -> Pin<Box<dyn Future<Output = ()> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn metric_data_before_handler<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 mut self,
_request: &'life1 Request<BoxBody<Bytes, Error>>,
_socket_data: &'life2 SocketData,
_metrics_sender: &'life3 MetricsMultiSender,
) -> Pin<Box<dyn Future<Output = ()> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Sends metric data before handling the request
Source§fn metric_data_after_handler<'life0, 'life1, 'async_trait>(
&'life0 mut self,
metrics_sender: &'life1 MetricsMultiSender,
) -> Pin<Box<dyn Future<Output = ()> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn metric_data_after_handler<'life0, 'life1, 'async_trait>(
&'life0 mut self,
metrics_sender: &'life1 MetricsMultiSender,
) -> Pin<Box<dyn Future<Output = ()> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Sends metric data after modifying the response
Source§fn response_modifying_handler<'life0, 'async_trait>(
&'life0 mut self,
response: Response<BoxBody<Bytes, Error>>,
) -> Pin<Box<dyn Future<Output = Result<Response<BoxBody<Bytes, Error>>, Box<dyn Error>>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn response_modifying_handler<'life0, 'async_trait>(
&'life0 mut self,
response: Response<BoxBody<Bytes, Error>>,
) -> Pin<Box<dyn Future<Output = Result<Response<BoxBody<Bytes, Error>>, Box<dyn Error>>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Modifies the outgoing response
Auto Trait Implementations§
impl Freeze for ReverseProxyHandler
impl !RefUnwindSafe for ReverseProxyHandler
impl Send for ReverseProxyHandler
impl Sync for ReverseProxyHandler
impl Unpin for ReverseProxyHandler
impl !UnwindSafe for ReverseProxyHandler
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more