pub struct HttpOptions {Show 19 fields
pub addr: String,
pub api_prefix: String,
pub cors: CorsOptions,
pub timeout_secs: u64,
pub body_limit_bytes: usize,
pub per_ip_rate_limit: Option<u32>,
pub rate_limit_store: Option<String>,
pub rate_limit_ipv6_prefix: u8,
pub security_headers: bool,
pub compression: bool,
pub maintenance_file: PathBuf,
pub maintenance_except: Vec<String>,
pub trust_proxy: bool,
pub trusted_proxies: Vec<String>,
pub signing_key: Option<Secret<String>>,
pub shutdown_grace_secs: u64,
pub errors: ErrorOptions,
pub server: ServerOptions,
pub multipart: MultipartLimits,
}Expand description
HTTP server settings (configuration section http; every key optional).
[http]
addr = "0.0.0.0:8080"
api_prefix = "/api"
timeout_secs = 30
cors = { allowed_origins = ["http://localhost:3000"] }
errors = { code = true }
server = { max_connections = 10000 }Fields§
§addr: StringThe address serve binds (default 127.0.0.1:8080).
api_prefix: StringThe prefix of every controller route (default /api); routes whose
path starts with ! ignore it.
cors: CorsOptionsCross-origin settings.
timeout_secs: u64The request timeout (default 30 s); routes may override it.
body_limit_bytes: usizeThe default request body limit (default 2 MiB); routes may override it.
per_ip_rate_limit: Option<u32>Requests per minute per client IP (default Some(600); None disables).
Counted in each process, and also in the store http.rate_limit_store
names when every process shares one ("redis" with RedisModule).
rate_limit_store: Option<String>Where the per-IP limit and route throttles also count: unset or
"memory", only in each process; else in the dyn RateLimitStore
registered under this name ("redis" with RedisModule) too, so every
process counts them together. A name nothing registered stops the boot.
rate_limit_ipv6_prefix: u8How much of an IPv6 address names a client for every per-IP limit
(this one, route throttles for guests, the sign-in throttles, the
OAuth endpoint limits): the first rate_limit_ipv6_prefix bits, so
all addresses of one network share one budget (default 64: one /64,
the smallest allocation a provider normally gives a customer; 1 to
128). IPv4 clients are counted per address, and IPv4-mapped IPv6
addresses (::ffff:192.0.2.1) as IPv4. See rate_limit_key.
security_headers: boolSend the default security headers (default true).
compression: boolCompress responses (default true): with gzip, and the pages and ops of
navree-ui with brotli. Off, no response is compressed by either. A route
opts out with no_compression and a
response with Cache-Control: no-transform, from both: see the BREACH
note on CompressionLayer.
maintenance_file: PathBufWhile this file exists the app answers 503 (default storage/framework/down).
maintenance_except: Vec<String>Request paths still served during maintenance, matched exactly
(default /health/live, /health/ready and /metrics, so probes and
scrapes keep working and an orchestrator does not restart instances
that are only down for maintenance). From the environment, a
comma-separated list (APP_HTTP__MAINTENANCE_EXCEPT=/health/live,/up).
trust_proxy: boolTake the client IP from X-Forwarded-For / X-Real-IP sent by any
peer (default false; enable only when every request comes through
a reverse proxy that sets them). Prefer trusted_proxies.
trusted_proxies: Vec<String>The reverse proxies (and backends-for-frontends) whose
X-Forwarded-For / X-Real-IP name the client: IP addresses or
CIDR blocks (127.0.0.1, ::1, 10.0.0.0/8). A request from any
other peer is identified by its own address, so clients reaching the
app directly cannot choose theirs. In X-Forwarded-For, the client
is the first address from the right that is not a listed proxy.
When set, it replaces trust_proxy. From the environment, a
comma-separated list (APP_HTTP__TRUSTED_PROXIES=127.0.0.1,::1).
signing_key: Option<Secret<String>>The key for signed URLs. When unset, a key derived from the app key
(app.key, or APP_KEY) is used; with no app key either, a random
per-process key, so signed URLs do not survive a restart.
shutdown_grace_secs: u64How long serve waits for in-flight requests after a shutdown signal
(default 30 s).
errors: ErrorOptionsHow error bodies are rendered (http.errors).
server: ServerOptionsThe limits on connections (http.server).
multipart: MultipartLimitsThe limits on multipart/form-data forms (http.multipart).
Implementations§
Source§impl HttpOptions
impl HttpOptions
Sourcepub fn rate_limit_key(&self, ip: IpAddr) -> IpAddr
pub fn rate_limit_key(&self, ip: IpAddr) -> IpAddr
The key a client’s per-IP limits are counted under: its IPv4 address,
or the network of its IPv6 address (rate_limit_ipv6_prefix).
Trait Implementations§
Source§impl Clone for HttpOptions
impl Clone for HttpOptions
Source§impl ConfigSection for HttpOptions
impl ConfigSection for HttpOptions
Source§const KEY: &'static str = "http"
const KEY: &'static str = "http"
"billing",
"mail.smtp").Source§fn validate(&self) -> Result<(), String>
fn validate(&self) -> Result<(), String>
KEY. The message must not echo secret values.Source§fn defaults() -> Option<Value>
fn defaults() -> Option<Value>
config:show --defaults. Leave out credentials: None (the default)
publishes nothing. defaults_of builds it from Default and
Serialize for a section that has no secret field.Source§fn schema() -> Option<SectionSchema>
fn schema() -> Option<SectionSchema>
None (the default) for a
section written by hand; #[derive(ConfigSection)] fills it in.