sxg_fallback_host

The `sxg_fallback_host` directive specifies the fallback hostname for generated Signed HTTP Exchanges (SXG).

Syntaxsxg_fallback_host hostname;
DefaultHost header value from the HTTP request.
Contextserver
Arguments1

Description

The sxg_fallback_host directive is an optional configuration parameter used in the context of the Signed HTTP Exchanges (SXG) module for NGINX. When generating SXG files, if the original request does not provide an appropriate host header for the signed exchange, this directive defines a fallback hostname that can be included within the SXG file. This ensures that any SXG generated can still be correctly resolved, even when the host cannot be determined from the request.

The value assigned to sxg_fallback_host should be a valid hostname, which the module will use when creating the SXG payload. When requested, if the SXG cannot include the necessary host from the request, it resorts to using this fallback host value. It's particularly useful when the server might be handling multiple hosts or when certain security mechanisms prevent the use of the original request-host header.

If this directive is not set, the default behavior will use the Host header parameter of the HTTP request, which may not always be desirable in scenarios where host-specific handling is not consistent or reliable. In such cases, explicitly setting the sxg_fallback_host ensures greater stability in signed exchanges generated by the server.

Config Example

server {
    listen 80;
    server_name example.com;

    sxg;
    sxg_certificate /path/to/cert.pem;
    sxg_certificate_key /path/to/cert.key;
    sxg_cert_url https://example.com/cert-url;
    sxg_fallback_host fallback.example.com;
}

Ensure that the fallback host is a valid and reachable hostname to avoid issues with SXG resolution.

Using an incorrect or non-existent fallback host may lead to failures in serving SXG files properly.

← Back to all directives