Struct static_web_server::settings::cli::General
source · pub struct General {Show 40 fields
pub host: String,
pub port: u16,
pub fd: Option<usize>,
pub threads_multiplier: usize,
pub max_blocking_threads: usize,
pub root: PathBuf,
pub page50x: PathBuf,
pub page404: PathBuf,
pub page_fallback: PathBuf,
pub log_level: String,
pub cors_allow_origins: String,
pub cors_allow_headers: String,
pub cors_expose_headers: String,
pub http2: bool,
pub http2_tls_cert: Option<PathBuf>,
pub http2_tls_key: Option<PathBuf>,
pub https_redirect: bool,
pub https_redirect_host: String,
pub https_redirect_from_port: u16,
pub https_redirect_from_hosts: String,
pub index_files: String,
pub compression: bool,
pub compression_level: CompressionLevel,
pub compression_static: bool,
pub directory_listing: bool,
pub directory_listing_order: u8,
pub directory_listing_format: DirListFmt,
pub security_headers: bool,
pub cache_control_headers: bool,
pub basic_auth: String,
pub grace_period: u8,
pub config_file: PathBuf,
pub log_remote_address: bool,
pub redirect_trailing_slash: bool,
pub ignore_hidden_files: bool,
pub health: bool,
pub experimental_metrics: bool,
pub maintenance_mode: bool,
pub maintenance_mode_status: StatusCode,
pub maintenance_mode_file: PathBuf,
/* private fields */
}
Expand description
General server configuration available in CLI and config file options.
Fields§
§host: String
Host address (E.g 127.0.0.1 or ::1)
port: u16
Host port
fd: Option<usize>
Instead of binding to a TCP port, accept incoming connections to an already-bound TCP socket listener on the specified file descriptor number (usually zero). Requires that the parent process (e.g. inetd, launchd, or systemd) binds an address and port on behalf of static-web-server, before arranging for the resulting file descriptor to be inherited by static-web-server. Cannot be used in conjunction with the port and host arguments. The included systemd unit file utilises this feature to increase security by allowing the static-web-server to be sandboxed more completely.
threads_multiplier: usize
Number of worker threads multiplier that’ll be multiplied by the number of system CPUs
using the formula: worker threads = number of CPUs * n
where n
is the value that changes here.
When multiplier value is 0 or 1 then one thread per core is used.
Number of worker threads result should be a number between 1 and 32,768 though it is advised to keep this value on the smaller side.
max_blocking_threads: usize
Maximum number of blocking threads
root: PathBuf
Root directory path of static files.
page50x: PathBuf
HTML file path for 50x errors. If the path is not specified or simply doesn’t exist then the server will use a generic HTML error message. If a relative path is used then it will be resolved under the root directory.
page404: PathBuf
HTML file path for 404 errors. If the path is not specified or simply doesn’t exist then the server will use a generic HTML error message. If a relative path is used then it will be resolved under the root directory.
page_fallback: PathBuf
fallback-page
only.HTML file path that is used for GET requests when the requested path doesn’t exist. The fallback page is served with a 200 status code, useful when using client routers. If the path is not specified or simply doesn’t exist then this feature will not be active.
log_level: String
Specify a logging level in lower case. Values: error, warn, info, debug or trace
cors_allow_origins: String
Specify an optional CORS list of allowed origin hosts separated by commas. Host ports or protocols aren’t being checked. Use an asterisk (*) to allow any host.
cors_allow_headers: String
Specify an optional CORS list of allowed headers separated by commas. Default “origin, content-type”. It requires --cors-allow-origins
to be used along with.
cors_expose_headers: String
Specify an optional CORS list of exposed headers separated by commas. Default “origin, content-type”. It requires --cors-expose-origins
to be used along with.
http2: bool
http2
only.Enable HTTP/2 with TLS support.
http2_tls_cert: Option<PathBuf>
http2
only.Specify the file path to read the certificate.
http2_tls_key: Option<PathBuf>
http2
only.Specify the file path to read the private key.
https_redirect: bool
http2
only.Redirect all requests with scheme “http” to “https” for the current server instance. It depends on “http2” to be enabled.
https_redirect_host: String
http2
only.Canonical host name or IP of the HTTPS (HTTPS/2) server. It depends on “https_redirect” to be enabled.
https_redirect_from_port: u16
http2
only.HTTP host port where the redirect server will listen for requests to redirect them to HTTPS. It depends on “https_redirect” to be enabled.
https_redirect_from_hosts: String
http2
only.List of host names or IPs allowed to redirect from. HTTP requests must contain the HTTP ‘Host’ header and match against this list. It depends on “https_redirect” to be enabled.
index_files: String
List of files that will be used as an index for requests ending with the slash character (‘/’). Files are checked in the specified order.
compression: bool
compression
or compression-gzip
or compression-brotli
or compression-zstd
or compression-deflate
only.Gzip, Deflate, Brotli or Zstd compression on demand determined by the Accept-Encoding header and applied to text-based web file types only.
compression_level: CompressionLevel
compression
or compression-gzip
or compression-brotli
or compression-zstd
or compression-deflate
only.Compression level to apply for Gzip, Deflate, Brotli or Zstd compression.
compression_static: bool
compression
or compression-gzip
or compression-brotli
or compression-zstd
or compression-deflate
only.Look up the pre-compressed file variant (.gz
, .br
or .zst
) on disk of a requested file and serves it directly if available.
The compression type is determined by the Accept-Encoding
header.
directory_listing: bool
directory-listing
only.Enable directory listing for all requests ending with the slash character (‘/’).
directory_listing_order: u8
directory-listing
only.Specify a default code number to order directory listing entries per Name
, Last modified
or Size
attributes (columns). Code numbers supported: 0 (Name asc), 1 (Name desc), 2 (Last modified asc), 3 (Last modified desc), 4 (Size asc), 5 (Size desc). Default 6 (unordered)
directory_listing_format: DirListFmt
directory-listing
only.Specify a content format for directory listing entries. Formats supported: “html” or “json”. Default “html”.
security_headers: bool
Enable security headers by default when HTTP/2 feature is activated. Headers included: “Strict-Transport-Security: max-age=63072000; includeSubDomains; preload” (2 years max-age), “X-Frame-Options: DENY” and “Content-Security-Policy: frame-ancestors ‘self’”.
cache_control_headers: bool
Enable cache control headers for incoming requests based on a set of file types. The file type list can be found on src/control_headers.rs
file.
basic_auth: String
basic-auth
only.It provides The “Basic” HTTP Authentication scheme using credentials as “user-id:password” pairs. Password must be encoded using the “BCrypt” password-hashing function.
grace_period: u8
Defines a grace period in seconds after a SIGTERM
signal is caught which will delay the server before to shut it down gracefully. The maximum value is 255 seconds.
config_file: PathBuf
Server TOML configuration file path.
log_remote_address: bool
Log incoming requests information along with its remote address if available using the info
log level.
redirect_trailing_slash: bool
Check for a trailing slash in the requested directory URI and redirect permanently (308) to the same path with a trailing slash suffix if it is missing.
Ignore hidden files/directories (dotfiles), preventing them to be served and being included in auto HTML index pages (directory listing).
health: bool
Add a /health endpoint that doesn’t generate any log entry and returns a 200 status code. This is especially useful with Kubernetes liveness and readiness probes.
experimental_metrics: bool
experimental
only.Add a /metrics endpoint that returns a Prometheus metrics response.
maintenance_mode: bool
Enable the server’s maintenance mode functionality.
maintenance_mode_status: StatusCode
Provide a custom HTTP status code when entering into maintenance mode. Default 503.
maintenance_mode_file: PathBuf
Provide a custom maintenance mode HTML file. If not provided then a generic message will be displayed.
Trait Implementations§
source§impl CommandFactory for General
impl CommandFactory for General
source§impl FromArgMatches for General
impl FromArgMatches for General
source§fn from_arg_matches(__clap_arg_matches: &ArgMatches) -> Result<Self, Error>
fn from_arg_matches(__clap_arg_matches: &ArgMatches) -> Result<Self, Error>
source§fn from_arg_matches_mut(
__clap_arg_matches: &mut ArgMatches
) -> Result<Self, Error>
fn from_arg_matches_mut( __clap_arg_matches: &mut ArgMatches ) -> Result<Self, Error>
source§fn update_from_arg_matches(
&mut self,
__clap_arg_matches: &ArgMatches
) -> Result<(), Error>
fn update_from_arg_matches( &mut self, __clap_arg_matches: &ArgMatches ) -> Result<(), Error>
ArgMatches
to self
.source§fn update_from_arg_matches_mut(
&mut self,
__clap_arg_matches: &mut ArgMatches
) -> Result<(), Error>
fn update_from_arg_matches_mut( &mut self, __clap_arg_matches: &mut ArgMatches ) -> Result<(), Error>
ArgMatches
to self
.