Struct static_web_server::settings::cli::General
source · pub struct General {Show 38 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_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 maintenance_mode: bool,
pub maintenance_mode_status: StatusCode,
pub maintenance_mode_file: PathBuf,
}Expand description
General server configuration available in CLI and config file options.
Fields§
§host: StringHost address (E.g 127.0.0.1 or ::1)
port: u16Host 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: usizeNumber 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: usizeMaximum number of blocking threads
root: PathBufRoot directory path of static files.
page50x: PathBufHTML 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: PathBufHTML 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: PathBuffallback-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: StringSpecify a logging level in lower case. Values: error, warn, info, debug or trace
cors_allow_origins: StringSpecify 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: StringSpecify 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: StringSpecify 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: boolhttp2 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: boolhttp2 only.Redirect all requests with scheme “http” to “https” for the current server instance. It depends on “http2” to be enabled.
https_redirect_host: Stringhttp2 only.Canonical host name or IP of the HTTPS (HTTPS/2) server. It depends on “https_redirect” to be enabled.
https_redirect_from_port: u16http2 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: Stringhttp2 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: StringList of files that will be used as an index for requests ending with the slash character (‘/’). Files are checked in the specified order.
compression: boolcompression 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_static: boolcompression 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: booldirectory-listing only.Enable directory listing for all requests ending with the slash character (‘/’).
directory_listing_order: u8directory-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: DirListFmtdirectory-listing only.Specify a content format for directory listing entries. Formats supported: “html” or “json”. Default “html”.
security_headers: boolEnable 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: boolEnable 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: StringIt 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: u8Defines 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: PathBufServer TOML configuration file path.
log_remote_address: boolLog incoming requests information along with its remote address if available using the info log level.
redirect_trailing_slash: boolCheck 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: boolAdd 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.
maintenance_mode: boolEnable the server’s maintenance mode functionality.
maintenance_mode_status: StatusCodeProvide a custom HTTP status code when entering into maintenance mode. Default 503.
maintenance_mode_file: PathBufProvide a custom maintenance mode HTML file. If not provided then a generic message will be displayed.
Trait Implementations§
source§impl Args for General
impl Args for General
source§fn group_id() -> Option<Id>
fn group_id() -> Option<Id>
ArgGroup::id][crate::ArgGroup::id] for this set of argumentssource§fn augment_args<'b>(__clap_app: Command) -> Command
fn augment_args<'b>(__clap_app: Command) -> Command
source§fn augment_args_for_update<'b>(__clap_app: Command) -> Command
fn augment_args_for_update<'b>(__clap_app: Command) -> Command
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.