pub struct General {Show 57 fields
pub host: String,
pub port: u16,
pub fd: Option<usize>,
pub unix_socket: Option<PathBuf>,
pub unix_socket_mode: Option<u32>,
pub unix_socket_force: bool,
pub threads_multiplier: usize,
pub max_blocking_threads: usize,
pub root: PathBuf,
pub use_relative_root: bool,
pub page50x: PathBuf,
pub page404: PathBuf,
pub page_fallback: PathBuf,
pub log_level: String,
pub log_format: LogFormat,
pub log_with_ansi: bool,
pub log_file: Option<PathBuf>,
pub cors_allow_origins: String,
pub cors_allow_headers: String,
pub cors_expose_headers: String,
pub tls: bool,
pub tls_cert: Option<PathBuf>,
pub tls_key: Option<PathBuf>,
pub http2: bool,
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 directory_listing_download: Vec<DirDownloadFmt>,
pub security_headers: bool,
pub cache_control_headers: bool,
pub etag: bool,
pub basic_auth: String,
pub grace_period: u8,
pub config_file: PathBuf,
pub log_remote_address: bool,
pub log_x_real_ip: bool,
pub log_forwarded_for: bool,
pub trusted_proxies: Vec<IpAddr>,
pub redirect_trailing_slash: bool,
pub include_hidden: bool,
pub follow_symlinks: bool,
pub accept_markdown: bool,
pub text_charset: bool,
pub health: bool,
pub metrics: bool,
pub maintenance_mode: bool,
pub maintenance_mode_status: StatusCode,
pub maintenance_mode_file: PathBuf,
pub commands: Option<Commands>,
/* private fields */
}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.
unix_socket: Option<PathBuf>Bind the server to a Unix Domain Socket (UDS) at the given filesystem path
instead of a TCP host/port. Useful for reverse-proxy setups (e.g. nginx) on the
same host where TCP/IP overhead is undesirable and filesystem-based access
control is preferred. Cannot be combined with --host, --port, --fd, or
TLS-related options. The socket file is removed on a graceful shutdown.
unix_socket_mode: Option<u32>Filesystem permission bits applied to the Unix socket file after binding,
expressed in octal (e.g. 660, 0660, or 0o660). When omitted the socket
is created with the process umask. Only meaningful together with --unix-socket.
unix_socket_force: boolWhen true, remove an existing socket file at --unix-socket before binding.
This is useful when the server was previously killed abruptly and left a stale
socket behind. Defaults to false to avoid clobbering an unrelated file.
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.
use_relative_root: boolResolve the web root directory at request time rather than at startup, allowing symlinked root directories to be swapped at runtime.
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.A HTML file path (not relative to the root) 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 doesn’t exist then the feature is not activated.
log_level: StringSpecify a logging level in lower case. Values: error, warn, info, debug or trace
log_format: LogFormatSpecify the logging output format. Values: json (structured single-line JSON for production) or pretty (human-readable text for development)
log_with_ansi: boolEnable or disable ANSI escape codes for colors and other text formatting of the log output. Only effective when --log-format pretty is used.
log_file: Option<PathBuf>Optional filesystem path to stream log records to in addition to stderr.
When set, logs are written asynchronously through a background worker
thread (non-blocking I/O), so the request path is never delayed by disk
writes. Missing parent directories are created on startup. ANSI escape
codes are always disabled for file output regardless of
--log-with-ansi. The file uses the format selected by
--log-format (JSON by default). The file is opened in append mode and
is not rotated by SWS, use an external tool (e.g. logrotate) for
rotation.
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.
tls: booltls only.Enable TLS/HTTPS support. Requires –tls-cert and –tls-key.
tls_cert: Option<PathBuf>tls only.Specify the file path to the TLS certificate.
tls_key: Option<PathBuf>tls only.Specify the file path to the TLS private key.
http2: boolhttp2 only.Enable HTTP/2 protocol support. Requires TLS to be enabled (–tls).
https_redirect: booltls only.Redirect all requests with scheme “http” to “https” for the current server instance. Requires TLS to be enabled (–tls).
https_redirect_host: Stringtls only.Canonical host name or IP of the HTTPS server. It depends on “https_redirect” to be enabled.
https_redirect_from_port: u16tls 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: Stringtls 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-brotli or compression-deflate or compression-gzip or compression-zstd or compression 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: CompressionLevelcompression-brotli or compression-deflate or compression-gzip or compression-zstd or compression only.Compression level to apply for Gzip, Deflate, Brotli or Zstd compression.
compression_static: boolLook 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”.
directory_listing_download: Vec<DirDownloadFmt>directory-listing-download only.Specify list of enabled format(s) for directory download. Format supported: targz. Default to empty list (disabled).
security_headers: boolEnable security headers by default when TLS 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.
etag: boolEnable weak ETag headers (W/"<mtime>-<size>") and full conditional request handling (If-None-Match, If-Match, If-Range). Composes with --cache-control-headers; emits validators on every static-file response so clients can revalidate hot HTML even when long max-age is configured elsewhere.
basic_auth: Stringbasic-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: 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.
log_x_real_ip: boolLog the X-Real-IP header for remote IP information.
log_forwarded_for: boolLog the X-Forwarded-For header for remote IP information
trusted_proxies: Vec<IpAddr>List of IPs to use X-Forwarded-For from. The default is to trust all
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.
Include hidden files/directories (dotfiles), allowing them to be served and listed in auto HTML index pages (directory listing). Disabled by default; hidden files return 404 Not Found.
follow_symlinks: boolFollow symbolic links when serving files or directories. Disabled by default; requests whose path contains any symlink component return 403 Forbidden.
accept_markdown: boolEnable markdown content negotiation. When a client sends Accept: text/markdown, serve .md or .html.md files if available.
text_charset: boolSet a default charset=utf-8 parameter on limited set of text responses that don’t already have one.
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.
metrics: boolmetrics only.Enable the /metrics endpoint that exposes Prometheus metrics for HTTP requests, connections, and latency.
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.
commands: Option<Commands>Subcommands for additional maintenance tasks, like installing and uninstalling the SWS Windows Service and generation of completions and man pages
Trait Implementations§
Source§impl Args for General
impl Args for General
Source§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
Command so it can instantiate self via
FromArgMatches::update_from_arg_matches_mut Read moreSource§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.