# Getting started

URL: https://scalws.com/docs/getting-started/
Source: `README.md` in the ScalWS repository

**https://scalws.com** · daemon `scalwsd` · CLI `scalwsctl` · Adaptive Runtime controller
`scalws-controller` · web administration `scalws-console` · Kubernetes `scalws-ingress`

A Linux web and application server written in Rust. It serves static files, runs PHP
through PHP-FPM, Node.js and Python applications, works as a reverse proxy and load
balancer, hosts several tenants with cgroup v2 limits, and runs in Kubernetes as an
application's web server, an Ingress controller or a Gateway API implementation. Its
**Adaptive Runtime** adds web-tier capacity only when the web tier is the bottleneck.

> **Status: 1.1.1.** Packages for AlmaLinux, Rocky Linux and
> Oracle Linux 8, 9 and 10 ([EL10 note](https://scalws.com/docs/guide/installation/#el10)),
> Fedora 44 (signed dnf repository), openSUSE Leap 16.0 and 15.6 and SLES 16.0 and 15 SP7
> (the same repository, with zypper), Debian 12 and 13 and Ubuntu 22.04, 24.04 and 26.04
> (signed apt repository), Alpine Linux 3.24 (signed apk repository), x86_64; every build
> is listed with checksums on
> [releases.scalws.com](https://releases.scalws.com/). Feedback and bug reports are welcome
> in the issues; security problems go through SECURITY.md.

## Highlights

* **Adaptive Runtime.** `scalws-controller` runs several `scalwsd` instances that share
  each listener through `SO_REUSEPORT`. It classifies which tier is saturated (web tier,
  PHP, Node.js, Python, memory, connections) and scales out only when the web tier is the
  limit; otherwise it logs why it did nothing. It is never on the request path and holds
  no TLS keys: if it stops, instances keep serving.
* **Kubernetes.** `scalws-ingress` turns `networking.k8s.io/v1` Ingress resources and the
  common `nginx.ingress.kubernetes.io/` annotations into ScalWS configuration, and serves
  the Gateway API (GatewayClass, Gateway, HTTPRoute, ReferenceGrant; core and extended
  conformance tests in CI). ScalWS also runs as the web server of an application pod, with
  PHP-FPM as a sidecar. A Helm chart is in deploy/helm.
* **ScalWS Console.** HTTPS web administration on port 8090, installed with the package:
  live traffic per site, the Adaptive Runtime's decisions and instances, upstream pools,
  logs, an audit trail, and every configuration setting, validated before it is applied.
* **Measured, losses included.** On bare metal against nginx 1.31.6, the installed 1.1.0
  package on six CPUs (three instances under `scalws-controller`) serves cache hits at
  1.71×, TLS + HTTP/2 small files at 1.09× and PHP at 1.06×; small static files (1.02×)
  and the reverse proxy (1.01×) are level; fixed responses (0.99×), 1 MiB files (0.99×),
  Node.js (0.96×) and Python (0.96×) are behind. On one CPU, proxy (1.06×), cache hits
  (1.68×) and TLS + HTTP/2 (1.24×) are ahead and the other six scenarios are at 0.93× to
  1.01×; closing those gaps is 1.2 work. Against 1.0.0 nothing regressed, and the new
  default HTTP/1 server and client make fixed responses 1.10× and the proxy 1.15× to 1.28×
  faster than 1.0.0's defaults. Peak memory was 122 to 130 MiB for the controller and
  three instances together against nginx's 102 to 130 MiB.
  The method, the host and every scenario are in the
  [1.1.0 report](https://scalws.com/docs/benchmarks/2026-11-19-xeon-110/) and on
  [scalws.com/benchmarks](https://scalws.com/benchmarks/). 1.1.1 measured level with 1.1.0
  in every scenario ([1.1.1 report](https://scalws.com/docs/benchmarks/2026-11-23-xeon-111/)).

## What works today

* **Protocols:** HTTP/1.1 and HTTP/2 (ALPN and h2c prior knowledge), TLS 1.2/1.3 via rustls
  with SNI certificate selection (exact and wildcard), ACME (HTTP-01) certificates renewed
  without a restart. HTTP/3 (QUIC) is in every package, opt-in per TLS listener
  (`http3: true`), also across several instances. HTTP/1.1 is served by ScalWS's own
  HTTP/1 server and upstream client by default (`hyper` remains selectable). Experimental
  and opt-in: eBPF network accounting (`--features ebpf`).
* **Model:** tenant → application → domain; one short site file per domain
  (`scalwsctl site add|list|remove`, `scalwsctl migrate` from nginx or Apache).
* **Routing:** exact, prefix and regex routes with method, header and query matchers;
  rewrites, request and response header changes, redirects, allow/deny lists, CORS,
  basic authentication (bcrypt, SHA crypt, Apache MD5 htpasswd), per-route body limit,
  timeout and rate limit; `.htaccess` support with a safe subset.
* **Handlers:** confined static files (conditional and range requests, precompressed
  assets, zero-copy sends), reverse proxy over TCP, TLS or Unix sockets with WebSocket
  tunnelling, fixed responses.
* **Load balancing:** named upstream pools with smooth round robin, least connections and
  rendezvous hashing, weights, affinity by cookie, header or client address, retries and
  passive health; members can be changed at runtime (`scalwsctl upstreams set`).
* **Managed runtimes:** PHP-FPM pools over FastCGI, Node.js processes, Python ASGI/WSGI
  servers (uvicorn, hypercorn, gunicorn) and containers (podman/docker), supervised with
  readiness, crash backoff, restart-loop detection, graceful drain and log capture.
* **Tenancy:** cgroup v2 limits per tenant (CPU, memory, pids, I/O weight) with live
  updates, per-tenant concurrency and rate quotas, per-tenant and per-application
  accounting.
* **Application profiles:** `scalwsctl detect /srv/app` recognises WordPress, WooCommerce,
  Laravel, Next.js, Django, Flask, FastAPI and generic PHP/Node/Python apps and proposes a
  configuration.
* **Response cache** (opt-in per application): memory and disk tiers, explicit freshness
  only, `Vary`, stale-while-revalidate, purge by URL, prefix or tag.
* **Security:** profile deny rules (e.g. `wp-config.php`, `.env`), per-IP connection and
  request limits with bounded memory, request-smuggling defences, strict SNI, slow-client
  timeouts, trusted proxies (`X-Forwarded-For`, PROXY protocol). Fixes from repeated
  internal security audits are recorded in [CHANGELOG.md](https://scalws.com/docs/changelog/); the threat model is in
  [docs/THREAT_MODEL.md](https://scalws.com/docs/threat-model/).
* **Control panels:** on cPanel and DirectAdmin servers ScalWS can take over the
  panel's web server (`scalwsctl panel enable`, automatic at the first install): it serves
  the panel's domains, subdomains, aliases, PHP pools, webmail and certificates, follows
  every panel change and gives the ports back with `scalwsctl panel disable`.
  In ScalPanel, ScalWS is the web server inside each website's container
  ([ScalPanel mode](https://scalws.com/docs/guide/scalpanel/): `scalpanel-webserver` reads the site's `site.json`)
  and can be the node's edge ([ScalPanel edge](https://scalws.com/docs/guide/scalpanel-edge/): network sets
  and country blocking, hotlink protection, prefixed previews, per-site access logs).
* **Operations:** validate-then-swap reloads that never drop traffic, rollback and diff,
  admin API on a Unix socket (optional mTLS), `scalwsctl` (check, reload, rollback, scale,
  purge, top, backup/restore, diagnose), Prometheus metrics and JSON access logs,
  diagnostics that correlate crash loops, OOM kills and pressure, and an optional local AI
  advisor that explains findings and never acts.

The multi-node control plane is designed ([ADR-0021](https://scalws.com/docs/adr/0021-multi-node-control-plane/)), not built.

## Install

AlmaLinux, Rocky Linux and Oracle Linux 8, 9 and 10 (for 10 see the
[EL10 note](https://scalws.com/docs/guide/installation/#el10)), Fedora 44 (x86_64), from the
signed ScalWS dnf repository, as root:

```sh
curl -o /etc/yum.repos.d/scalws.repo https://rpm.scalws.com/scalws.repo
dnf install scalws
```

dnf asks once to import the signing key: its fingerprint must be
`0B49 CE44 88DC 3A3E 4F63  1218 CBBB F99C 69B9 9EF0`. SELinux stays enforcing; the package
brings its own policy module.

openSUSE Leap 16.0 and 15.6, SLES 16.0 and 15 SP7 (x86_64), from the same repository with
zypper, as root:

```sh
FPR=0B49CE4488DC3A3E4F631218CBBBF99C69B99EF0
key=$(mktemp)
curl -fsSL https://rpm.scalws.com/RPM-GPG-KEY-scalws -o "$key"
# The file must hold exactly one primary key, the pinned one; anything else is not imported.
if test "$(gpg --show-keys --with-colons "$key" \
    | awk -F: '$1=="pub"{p=1;next} p&&$1=="fpr"{print $10;p=0}')" = "$FPR"; then
    rpm --import "$key" && echo "repository key OK"
else
    echo "WRONG repository key: not imported, stop here"
fi
rm -f "$key"
zypper addrepo https://rpm.scalws.com/scalws.repo
zypper install scalws
```

On SUSE 16 SELinux stays enforcing with the same policy module; on SUSE 15 (AppArmor)
ScalWS runs unconfined, as on Debian and Ubuntu.

Alpine Linux 3.24 (x86_64, OpenRC) installs from the signed apk repository at
`https://apt.scalws.com/alpine/v3.24/main` with `apk add scalws` after adding its key
([Alpine Linux](https://scalws.com/docs/guide/installation/#alpine-linux)).

Debian 12 and 13, Ubuntu 22.04, 24.04 and 26.04 (amd64), from the signed ScalWS apt
repository (for the control panels that run on each system see the
[panel and system matrix](https://scalws.com/docs/guide/control-panels/#panels-and-systems)):

```sh
FPR=0B49CE4488DC3A3E4F631218CBBBF99C69B99EF0
apt-get install -y curl gnupg
key=$(mktemp)
curl -fsSL https://apt.scalws.com/scalws-archive-keyring.gpg -o "$key"
# The file must hold exactly one primary key, the pinned one: stop if this says WRONG.
test "$(gpg --show-keys --with-colons "$key" \
    | awk -F: '$1=="pub"{p=1;next} p&&$1=="fpr"{print $10;p=0}')" = "$FPR" \
    && echo "repository key OK" || echo "WRONG repository key: stop here"
# Install only that key, re-exported from a scratch keyring (never the downloaded file).
export GNUPGHOME=$(mktemp -d)
gpg --quiet --import "$key"
gpg --export "$FPR" > /usr/share/keyrings/scalws-archive-keyring.gpg
rm -rf "$GNUPGHOME" "$key"; unset GNUPGHOME
echo 'deb [signed-by=/usr/share/keyrings/scalws-archive-keyring.gpg] https://apt.scalws.com stable main' \
    > /etc/apt/sources.list.d/scalws.list
apt update && apt install scalws
```

The server starts on ports 80 and 443 right away, and the first install opens both ports
in an active ufw or a running firewalld (never the console's port 8090). To publish a site,
point the domain's DNS at the server and add it; HTTPS comes from Let's Encrypt
automatically:

```sh
sudo scalwsctl site add example.com      # files go to /srv/www/example.com
```

Supported systems, SELinux, SUSE, the firewall and cgroup v1 on EL8:
[installation guide](https://scalws.com/docs/guide/installation/). On a server with a
control panel, see [Control panels](https://scalws.com/docs/guide/control-panels/) for the
panel and system matrix.

`scalws-controller` (Adaptive Runtime) runs and supervises the `scalwsd` instances and is
what the console manages. Configurations with managed PHP/Node.js/Python runtimes run
under `scalwsd.service` instead (`systemctl enable --now scalwsd`); under the controller,
use an existing PHP-FPM pool and proxy to applications you run. The two units exclude
each other, and the console's management actions need the controller.

Configuration: `/etc/scalws/scalws.yaml`; console: `https://<host>:8090` (see
docs/OPERATIONS.md). The same packages are attached to each
[GitHub release](https://github.com/xsmtx/scalws/releases) for a one-off
`apt install ./scalws_*.deb`, `dnf install ./scalws-*.rpm` or
`zypper install ./scalws-*.rpm`; only the repositories bring updates.

## Documentation

* [Getting started](https://scalws.com/docs/getting-started/) and the
  [quick start](https://scalws.com/docs/guide/quick-start/): a static site, a PHP site, a
  Node.js application and HTTPS in five minutes
* Guides: [configuration](https://scalws.com/docs/guide/configuration/),
  [applications and runtimes](https://scalws.com/docs/guide/applications/),
  [load balancing](https://scalws.com/docs/guide/load-balancing/),
  [TLS](https://scalws.com/docs/guide/tls/), [security](https://scalws.com/docs/guide/security/),
  [Adaptive Runtime](https://scalws.com/docs/adaptive-runtime/)
* Kubernetes: [application pods](https://scalws.com/docs/guide/kubernetes/),
  [Ingress controller](https://scalws.com/docs/guide/ingress-controller/),
  [Gateway API](https://scalws.com/docs/guide/gateway-api/)
* [Control panels](https://scalws.com/docs/guide/control-panels/): cPanel and DirectAdmin
* How-to: [WordPress](https://scalws.com/docs/howto/wordpress/),
  [Laravel](https://scalws.com/docs/howto/laravel/),
  [Node.js](https://scalws.com/docs/howto/nodejs/), [Python](https://scalws.com/docs/howto/python/),
  [reverse proxy](https://scalws.com/docs/howto/reverse-proxy/)
* [Configuration reference](https://scalws.com/docs/reference/) (every setting) and the
  architecture decisions

## Quick start from source

```sh
cargo build --release
./target/release/scalwsctl check examples/scalws.yaml        # needs the referenced files
./target/release/scalwsd --config examples/scalws.yaml
kill -HUP $(pidof scalwsd)                            # reload
curl -s 127.0.0.1:9901/metrics | grep scalws_http_requests_total
```

## Layout

```
cmd/       scalwsd (server), scalwsctl (CLI), scalws-controller (Adaptive Runtime),
           scalws-console (web administration), scalws-ingress (Ingress and Gateway API)
crates/    scalws-* libraries: http, h1, tls, router, static, proxy, cache, security,
           htaccess, runtime(-php|-node|-python|-container), cgroups, observe, diag, ai, ...
deploy/    Helm chart and Kubernetes examples (static, PHP, Ingress, Gateway API)
packaging/ nfpm (DEB/RPM), systemd units, container image
docs/      guides, reference, ADRs (docs/adr), benchmarks, threat model
bench/     benchmark harness and comparison configs; tests/ integration and e2e tests
```

## Development

```sh
scripts/linux-test.sh --docker         # fmt, clippy and the full test suite in a Linux container
cargo test --workspace                 # on Linux (several crates are Linux-only)
cargo deny check && cargo audit        # supply chain (CI runs both)
```

Benchmarks: see [bench/README.md](https://scalws.com/docs/benchmarks/harness/).

## Feedback

Bug reports, questions and test results are welcome in the
[issues](https://github.com/xsmtx/scalws/issues). Please report security problems
privately, see SECURITY.md.

## License

ScalWS is free software under the GNU Affero General Public License v3.0
(AGPL-3.0-only), see LICENSE.

* Running ScalWS unmodified to serve your sites creates no obligation.
* If you modify ScalWS and let others use it over a network, you must offer those users
  the source of your modified version under the same licence.

"ScalWS" is a trademark of its author. Forks must use another name.
