Skip to content

HTTP/2

SWS provides HTTP/2 protocol support.

This feature is disabled by default and can be activated via the boolean --http2 option. HTTP/2 requires TLS to be enabled; pass --tls, --tls-cert and --tls-key alongside --http2.

Tips

  • --http2 requires TLS. Always pass --tls --tls-cert <path> --tls-key <path> together with --http2.
  • When HTTP/2 is enabled, Security Headers are also enabled automatically (via TLS).
  • See the TLS page for supported key formats and cipher suite defaults.
  • The server provides Termination Signal handling with Graceful Shutdown ability by default.

Example

Below is an example of how to run the server with HTTP/2 over TLS.

sh
static-web-server \
    --host 127.0.0.1 \
    --port 8787 \
    --root ./my-public-dir \
    --tls \
    --tls-cert ./my-tls.cert \
    --tls-key ./my-tls.key \
    --http2