ReverseProxyHandler

Struct ReverseProxyHandler 

Source
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

Source

fn status_response(status_code: StatusCode) -> ResponseData

Source

async fn mark_backend_failure(&mut self, upstream: &UpstreamInner)

Source

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>

Source

fn io_error_status(err: &Error) -> (StatusCode, &'static str)

Trait Implementations§

Source§

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,

Handles incoming HTTP requests and proxies them to the configured backend server(s)

This handler:

  1. Determines which backend server to proxy to (supports load balancing)
  2. Transforms the request by:
    • Converting the URL to match the backend format
    • Setting appropriate headers (Host, X-Forwarded-*)
  3. Establishes a connection to the backend (HTTP or HTTPS)
  4. 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,

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,

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,

Modifies the outgoing response
Source§

fn get_name(&self) -> &'static str

Gets the module handlers’ type name

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more