pub struct HstsConfig {
pub enabled: Option<bool>,
pub max_age: Option<u32>,
pub include_subdomains: Option<bool>,
pub preload: Option<bool>,
pub force_replace_backend: Option<bool>,
}Expand description
HSTS (HTTP Strict Transport Security, RFC 6797) policy attached to
an HTTPS listener default or per-frontend. The materialised
Strict-Transport-Security: max-age=N[; includeSubDomains][; preload]
header is injected on every successful HTTPS response (including
proxy-generated 3xx/401/5xx default answers). Per RFC 6797 §7.2 the
header MUST NOT be emitted on plaintext-HTTP responses; sozu rejects
HSTS configured on an HttpListenerConfig at config-load time and gates
the runtime injection on context.protocol == Protocol::HTTPS.
Validation:
enabled = truewithmax_age = Nonedefaultsmax_ageto 31536000 seconds (1 year) at config-load.max_age = 0is the RFC 6797 §11.4 kill-switch and is allowed silently;0 < max_age < 86400warns.preload = truewithmax_age < 31536000orinclude_subdomains != truewarns (Chrome HSTS preload list prerequisites at https://hstspreload.org/).preloadis opt-in only; never default-true (RFC 6797 §14.2 — removal from the preload list is slow and partial).
Fields§
§enabled: Option<bool>Whether HSTS is enabled for this scope. Required whenever the
parent message includes an HstsConfig — the partial-update path
treats enabled = false as the explicit-disable signal.
max_age: Option<u32>Strict-Transport-Security max-age directive in seconds. When
enabled = true and this is unset, sozu substitutes 31536000
(1 year, HSTS preload list minimum) at config-load.
include_subdomains: Option<bool>Append ; includeSubDomains to the rendered header.
preload: Option<bool>Append ; preload to the rendered header. Opt-in only — see
RFC 6797 §14.2 and https://hstspreload.org/.
force_replace_backend: Option<bool>Operator opt-in to override any backend-supplied
Strict-Transport-Security header with sozu’s typed policy.
RFC 6797 §6.1 default behaviour is to PRESERVE a backend-emitted
STS header when one is already present (sozu’s HSTS edit uses
HeaderEditMode::SetIfAbsent). That keeps the backend’s intent
intact for upstreams that ship their own HSTS policy.
Set this to true for the harden-centrally case: backends behind
sozu emit a stale or weak HSTS policy (e.g. legacy max-age=300)
and the operator wants to enforce a stronger policy at the proxy
edge unconditionally. The materialiser then uses
HeaderEditMode::Set instead of SetIfAbsent, replacing every
backend-supplied STS header with sozu’s rendered value.
Cite: https://datatracker.ietf.org/doc/html/rfc6797#section-6.1
Implementations§
Source§impl HstsConfig
impl HstsConfig
Sourcepub fn enabled(&self) -> bool
pub fn enabled(&self) -> bool
Returns the value of enabled, or the default value if enabled is unset.
Sourcepub fn max_age(&self) -> u32
pub fn max_age(&self) -> u32
Returns the value of max_age, or the default value if max_age is unset.
Sourcepub fn include_subdomains(&self) -> bool
pub fn include_subdomains(&self) -> bool
Returns the value of include_subdomains, or the default value if include_subdomains is unset.
Sourcepub fn preload(&self) -> bool
pub fn preload(&self) -> bool
Returns the value of preload, or the default value if preload is unset.
Sourcepub fn force_replace_backend(&self) -> bool
pub fn force_replace_backend(&self) -> bool
Returns the value of force_replace_backend, or the default value if force_replace_backend is unset.
Trait Implementations§
Source§impl Clone for HstsConfig
impl Clone for HstsConfig
Source§fn clone(&self) -> HstsConfig
fn clone(&self) -> HstsConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for HstsConfig
impl Debug for HstsConfig
Source§impl Default for HstsConfig
impl Default for HstsConfig
Source§impl<'de> Deserialize<'de> for HstsConfig
impl<'de> Deserialize<'de> for HstsConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Hash for HstsConfig
impl Hash for HstsConfig
Source§impl Message for HstsConfig
impl Message for HstsConfig
Source§fn encoded_len(&self) -> usize
fn encoded_len(&self) -> usize
Source§fn encode(&self, buf: &mut impl BufMut) -> Result<(), EncodeError>where
Self: Sized,
fn encode(&self, buf: &mut impl BufMut) -> Result<(), EncodeError>where
Self: Sized,
Source§fn encode_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
fn encode_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
Source§fn encode_length_delimited(
&self,
buf: &mut impl BufMut,
) -> Result<(), EncodeError>where
Self: Sized,
fn encode_length_delimited(
&self,
buf: &mut impl BufMut,
) -> Result<(), EncodeError>where
Self: Sized,
Source§fn encode_length_delimited_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
fn encode_length_delimited_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
Source§fn decode(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
fn decode(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
Source§fn decode_length_delimited(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
fn decode_length_delimited(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
Source§fn merge(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
fn merge(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
self. Read moreSource§fn merge_length_delimited(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
fn merge_length_delimited(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
self.Source§impl Ord for HstsConfig
impl Ord for HstsConfig
Source§fn cmp(&self, other: &HstsConfig) -> Ordering
fn cmp(&self, other: &HstsConfig) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for HstsConfig
impl PartialEq for HstsConfig
Source§fn eq(&self, other: &HstsConfig) -> bool
fn eq(&self, other: &HstsConfig) -> bool
self and other values to be equal, and is used by ==.Source§impl PartialOrd for HstsConfig
impl PartialOrd for HstsConfig
Source§impl Serialize for HstsConfig
impl Serialize for HstsConfig
impl Copy for HstsConfig
impl Eq for HstsConfig
impl StructuralPartialEq for HstsConfig
Auto Trait Implementations§
impl Freeze for HstsConfig
impl RefUnwindSafe for HstsConfig
impl Send for HstsConfig
impl Sync for HstsConfig
impl Unpin for HstsConfig
impl UnsafeUnpin for HstsConfig
impl UnwindSafe for HstsConfig
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.