pub struct Config {Show 53 fields
pub target_host: String,
pub target_port: u16,
pub upstream_command: Option<String>,
pub upstream_args: Vec<String>,
pub cache_size_bytes: usize,
pub max_cache_item_size_bytes: usize,
pub x_sendfile_enabled: bool,
pub gzip_compression_enabled: bool,
pub max_request_body: usize,
pub tls_domains: Vec<String>,
pub tls_cert_path: Option<String>,
pub tls_key_path: Option<String>,
pub acme_directory_url: String,
pub eab_kid: Option<String>,
pub eab_hmac_key: Option<String>,
pub storage_path: String,
pub bad_gateway_page: String,
pub http_port: u16,
pub https_port: u16,
pub http_idle_timeout: Duration,
pub http_read_timeout: Duration,
pub http_write_timeout: Duration,
pub h2c_enabled: bool,
pub forward_headers: bool,
pub log_requests: bool,
pub log_level: LogLevel,
pub shutdown_timeout_secs: u64,
pub database_url: Option<String>,
pub pg_channel_cache_invalidation: String,
pub pg_channel_config_update: String,
pub pg_channel_health: String,
pub redis_url: Option<String>,
pub toml_config: Option<TomlConfig>,
pub rate_limit_enabled: bool,
pub rate_limit_requests_per_sec: u32,
pub rate_limit_burst_size: u32,
pub upstream_timeout: Duration,
pub circuit_breaker_enabled: bool,
pub circuit_breaker_failure_threshold: u32,
pub circuit_breaker_timeout_secs: u64,
pub max_concurrent_requests: usize,
pub metrics_enabled: bool,
pub metrics_port: u16,
pub static_enabled: bool,
pub static_root: PathBuf,
pub static_paths: Vec<String>,
pub static_cache_control: String,
pub static_gzip_enabled: bool,
pub static_index_files: Vec<String>,
pub static_fallthrough: bool,
pub static_inline_size_limit: u64,
pub client_ip_header: Option<String>,
pub trusted_ranges_file: Option<PathBuf>,
}Expand description
WarpDrive configuration
This struct contains all configuration options for WarpDrive, including proxy settings, caching, TLS/ACME, and PostgreSQL/Redis coordination features.
Fields§
§target_host: StringHostname or IP of the upstream server to proxy to
target_port: u16Port of the upstream server to proxy to
upstream_command: Option<String>Command to spawn upstream process (for supervision)
upstream_args: Vec<String>Arguments for upstream command
cache_size_bytes: usizeTotal cache size in bytes
max_cache_item_size_bytes: usizeMaximum size for a single cached item in bytes
x_sendfile_enabled: boolEnable X-Sendfile header support
gzip_compression_enabled: boolEnable gzip compression
max_request_body: usizeMaximum request body size in bytes (0 = unlimited)
tls_domains: Vec<String>List of domains for TLS certificates
tls_cert_path: Option<String>Path to TLS certificate file (PEM format) - for self-signed or manual certs
tls_key_path: Option<String>Path to TLS private key file (PEM format) - for self-signed or manual certs
acme_directory_url: StringACME directory URL for certificate provisioning
eab_kid: Option<String>External Account Binding (EAB) key ID
eab_hmac_key: Option<String>External Account Binding (EAB) HMAC key
storage_path: StringStorage path for TLS certificates and state
bad_gateway_page: StringPath to custom 502 Bad Gateway HTML page
http_port: u16HTTP listen port
https_port: u16HTTPS listen port
http_idle_timeout: DurationHTTP idle timeout
http_read_timeout: DurationHTTP read timeout
http_write_timeout: DurationHTTP write timeout
h2c_enabled: boolEnable HTTP/2 cleartext (h2c) support for AWS ALB and Cloud Run
forward_headers: boolForward X-Forwarded-* headers to upstream
log_requests: boolEnable request logging
log_level: LogLevelLog level
shutdown_timeout_secs: u64Graceful shutdown timeout in seconds
database_url: Option<String>PostgreSQL connection URL for coordination
pg_channel_cache_invalidation: StringPostgreSQL NOTIFY channel for cache invalidation
pg_channel_config_update: StringPostgreSQL NOTIFY channel for configuration updates
pg_channel_health: StringPostgreSQL NOTIFY channel for health checks
redis_url: Option<String>Redis connection URL for distributed cache
toml_config: Option<TomlConfig>TOML configuration for advanced routing (None = simple mode)
rate_limit_enabled: boolEnable rate limiting per IP
rate_limit_requests_per_sec: u32Maximum requests per second per IP
rate_limit_burst_size: u32Rate limit burst size (tokens available immediately)
upstream_timeout: DurationUpstream request timeout
circuit_breaker_enabled: boolEnable circuit breaker
circuit_breaker_failure_threshold: u32Circuit breaker failure threshold (failures before opening)
circuit_breaker_timeout_secs: u64Circuit breaker timeout (seconds before trying half-open)
max_concurrent_requests: usizeMaximum concurrent requests (0 = unlimited)
metrics_enabled: boolEnable Prometheus metrics endpoint
metrics_port: u16Port for Prometheus metrics HTTP server
static_enabled: boolEnable static file serving
static_root: PathBufRoot directory for static files
static_paths: Vec<String>URL paths that should be served as static files
static_cache_control: StringCache-Control header for static files
static_gzip_enabled: boolEnable gzip compression for static files
static_index_files: Vec<String>Index files to serve for directory requests
static_fallthrough: boolIf true, continue to backend if static file not found; if false, return 404
static_inline_size_limit: u64Maximum file size to keep in memory (larger files are streamed)
client_ip_header: Option<String>Header name to extract real client IP from (e.g., “CF-Connecting-IP”, “X-Real-IP”)
trusted_ranges_file: Option<PathBuf>Path to file containing trusted IP ranges (CIDR format, one per line)
Implementations§
Source§impl Config
impl Config
Sourcepub fn from_env() -> Result<Self, String>
pub fn from_env() -> Result<Self, String>
Create configuration from environment variables
Loads configuration from environment variables, with support for both
prefixed (WARPDRIVE_*) and unprefixed variables. Prefixed variables
take precedence. Falls back to sensible defaults for all values.
§Errors
Returns an error if .env file exists but cannot be loaded.
§Example
use warpdrive::config::Config;
let config = Config::from_env().expect("Failed to load config");Sourcepub fn has_tls(&self) -> bool
pub fn has_tls(&self) -> bool
Check if TLS is enabled
Returns true if either:
- TLS certificate/key paths are provided (self-signed/manual), OR
- At least one TLS domain is configured (ACME)
Sourcepub fn has_manual_tls(&self) -> bool
pub fn has_manual_tls(&self) -> bool
Check if using manual TLS certificates (vs ACME)
Sourcepub fn has_acme_domains(&self) -> bool
pub fn has_acme_domains(&self) -> bool
Check if ACME certificate provisioning is needed
Returns true if TLS domains are configured (without manual certs)
Sourcepub fn validate(&self) -> Result<(), String>
pub fn validate(&self) -> Result<(), String>
Validate configuration
Performs validation checks on the configuration to ensure it’s internally consistent and meets requirements.
§Errors
Returns an error if:
- TLS domains are specified without required ACME configuration
- TLS certificate path specified without key path (or vice versa)
- Ports are invalid (0 or above 65535)
- Cache sizes are invalid
- Database/Redis URLs are malformed