pub struct ReverseProxyBuilder<'a> {Show 17 fields
pub(super) connections: &'a mut Connections,
pub(super) upstreams: Vec<(Upstream, Option<usize>, Option<Duration>)>,
pub(super) lb_algorithm: LoadBalancerAlgorithm,
pub(super) lb_health_check_window: Duration,
pub(super) lb_health_check_max_fails: u64,
pub(super) lb_health_check: bool,
pub(super) lb_retry_connection: bool,
pub(super) proxy_no_verification: bool,
pub(super) proxy_intercept_errors: bool,
pub(super) proxy_http2_only: bool,
pub(super) proxy_http2: bool,
pub(super) proxy_keepalive: bool,
pub(super) proxy_proxy_header: Option<ProxyHeader>,
pub(super) proxy_request_header: Vec<(HeaderName, String)>,
pub(super) proxy_request_header_replace: Vec<(HeaderName, String)>,
pub(super) proxy_request_header_remove: Vec<HeaderName>,
pub(super) rewrite_host: bool,
}Expand description
Builder for configuring and constructing a ReverseProxy.
Fields§
§connections: &'a mut Connections§upstreams: Vec<(Upstream, Option<usize>, Option<Duration>)>§lb_algorithm: LoadBalancerAlgorithm§lb_health_check_window: Duration§lb_health_check_max_fails: u64§lb_health_check: bool§lb_retry_connection: bool§proxy_no_verification: bool§proxy_intercept_errors: bool§proxy_http2_only: bool§proxy_http2: bool§proxy_keepalive: bool§proxy_proxy_header: Option<ProxyHeader>§proxy_request_header: Vec<(HeaderName, String)>§proxy_request_header_replace: Vec<(HeaderName, String)>§proxy_request_header_remove: Vec<HeaderName>§rewrite_host: boolImplementations§
Source§impl<'a> ReverseProxyBuilder<'a>
impl<'a> ReverseProxyBuilder<'a>
Sourcepub fn upstream(
self,
proxy_to: String,
proxy_unix: Option<String>,
local_limit: Option<usize>,
keepalive_idle_timeout: Option<Duration>,
) -> Self
pub fn upstream( self, proxy_to: String, proxy_unix: Option<String>, local_limit: Option<usize>, keepalive_idle_timeout: Option<Duration>, ) -> Self
Adds an upstream backend target.
proxy_to is the backend URL (for example http://127.0.0.1:8080).
proxy_unix can be used to target a Unix socket path.
local_limit controls per-upstream connection limit.
keepalive_idle_timeout sets pooled connection idle timeout.
Sourcepub fn upstream_srv(
self,
to: String,
local_limit: Option<usize>,
keepalive_idle_timeout: Option<Duration>,
secondary_runtime_handle: Handle,
dns_servers: Vec<IpAddr>,
) -> Self
pub fn upstream_srv( self, to: String, local_limit: Option<usize>, keepalive_idle_timeout: Option<Duration>, secondary_runtime_handle: Handle, dns_servers: Vec<IpAddr>, ) -> Self
Adds a dynamic (SRV-based) upstream backend target.
to is the backend URL (for example http://_http._tcp.example.com).
local_limit controls per-upstream connection limit.
keepalive_idle_timeout sets pooled connection idle timeout.
Sourcepub fn lb_algorithm(self, algorithm: LoadBalancerAlgorithm) -> Self
pub fn lb_algorithm(self, algorithm: LoadBalancerAlgorithm) -> Self
Sets load balancing algorithm.
Sourcepub fn lb_health_check_window(self, window: Duration) -> Self
pub fn lb_health_check_window(self, window: Duration) -> Self
Sets health-check TTL window for failed backend counters.
Sourcepub fn lb_health_check_max_fails(self, max_fails: u64) -> Self
pub fn lb_health_check_max_fails(self, max_fails: u64) -> Self
Sets maximum consecutive failed checks before a backend is considered unhealthy.
Sourcepub fn lb_health_check(self, enable: bool) -> Self
pub fn lb_health_check(self, enable: bool) -> Self
Enables or disables backend health checks.
Sourcepub fn proxy_no_verification(self, no_verification: bool) -> Self
pub fn proxy_no_verification(self, no_verification: bool) -> Self
Disables certificate verification for upstream TLS connections.
Sourcepub fn proxy_intercept_errors(self, intercept_errors: bool) -> Self
pub fn proxy_intercept_errors(self, intercept_errors: bool) -> Self
Intercepts upstream errors and converts them to proxy-generated responses.
Sourcepub fn lb_retry_connection(self, retry: bool) -> Self
pub fn lb_retry_connection(self, retry: bool) -> Self
Enables retrying a different backend when connection setup fails.
Sourcepub fn proxy_http2_only(self, http2_only: bool) -> Self
pub fn proxy_http2_only(self, http2_only: bool) -> Self
Forces HTTP/2-only upstream connections.
Sourcepub fn proxy_http2(self, http2: bool) -> Self
pub fn proxy_http2(self, http2: bool) -> Self
Enables HTTP/2 support for upstream connections.
Sourcepub fn proxy_keepalive(self, keepalive: bool) -> Self
pub fn proxy_keepalive(self, keepalive: bool) -> Self
Enables connection pooling and keepalive reuse.
Sourcepub fn proxy_proxy_header(self, proxy_header: Option<ProxyHeader>) -> Self
pub fn proxy_proxy_header(self, proxy_header: Option<ProxyHeader>) -> Self
Sets PROXY protocol header mode for upstream connections.
Sourcepub fn proxy_request_header(
self,
header_name: HeaderName,
header_value: String,
) -> Self
pub fn proxy_request_header( self, header_name: HeaderName, header_value: String, ) -> Self
Adds a request header to upstream requests.
Sourcepub fn proxy_request_header_replace(
self,
header_name: HeaderName,
header_value: String,
) -> Self
pub fn proxy_request_header_replace( self, header_name: HeaderName, header_value: String, ) -> Self
Replaces a request header on upstream requests.
Sourcepub fn proxy_request_header_remove(self, header_name: HeaderName) -> Self
pub fn proxy_request_header_remove(self, header_name: HeaderName) -> Self
Removes a request header from upstream requests.
Sourcepub fn rewrite_host(self, rewrite_host: bool) -> Self
pub fn rewrite_host(self, rewrite_host: bool) -> Self
Enables or disables Host header rewriting for non-HTTPS upstream requests.
Sourcepub fn build(self) -> ReverseProxy
pub fn build(self) -> ReverseProxy
Builds a ReverseProxy from the configured options.