Skip to main content

Air-gapped deployment

The gateway makes a handful of optional outbound requests that have nothing to do with serving traffic: it refreshes the model price map, pulls the Admin UI blog feed, and so on. Each of these has always had its own opt-out variable. SPANWAY_AIRGAPPED turns all of them off at once.

export SPANWAY_AIRGAPPED=true

The switch accepts true, 1 or yes, case-insensitive. Anything else, including an unset variable, leaves the gateway in its default mode. When it is on, every fetch in the table below skips the network and serves the file bundled in the image, without logging a warning. The gateway logs one info line at startup saying the mode is on, which shows only when the log level is INFO or lower, for example with SPANWAY_LOG=INFO. At the default level the line is hidden and /health/readiness is the way to check the mode. Requests to your LLM providers are not affected, those go wherever your api_base points.

The per-fetch variables keep working. SPANWAY_AIRGAPPED is simply the union of them, so you can still turn off a single fetch on a connected gateway.

A real-world scenario​

A defence contractor runs the gateway in a network with no route to the internet. Model traffic goes to providers inside their own cloud tenancy. They set one variable so the gateway never tries to fetch prices or the blog feed, mirror the image and chart into their registry, and check from a probe that the mode is on.

Steps​

  1. Mirror the image and the chart into your registry, as shown in Mirroring the container images and Mirroring the Helm chart.

  2. Set SPANWAY_AIRGAPPED=true in the gateway environment and deploy from the mirror.

  3. Confirm the mode.

    curl -s http://localhost:4000/health/readiness
  4. Sign in to the Admin UI at /ui. The Home page shows no blog posts and no launches, because those feeds are skipped.

Expected result​

/health/readiness answers "airgapped": true and no fetch warnings follow. With SPANWAY_LOG=INFO the gateway log also has one line saying the mode is on.

What the switch covers​

This table is the gateway's catalogue of optional fetches. A unit test checks that every entry is wired to the switch, so the list cannot drift from the code.

FetchURL variablePer-fetch switchOffline fallback
Model cost mapSPANWAY_MODEL_COST_MAP_URLSPANWAY_LOCAL_MODEL_COST_MAPmodel_prices_and_context_window_backup.json bundled in the image
Admin UI blog feedSPANWAY_BLOG_POSTS_URLSPANWAY_LOCAL_BLOG_POSTSblog_posts.json bundled in the image
Anthropic beta headers configSPANWAY_ANTHROPIC_BETA_HEADERS_URLSPANWAY_LOCAL_ANTHROPIC_BETA_HEADERSanthropic_beta_headers_config.json bundled in the image
Auto-router presetsSPANWAY_AUTOROUTER_PRESETS_URLSPANWAY_LOCAL_AUTOROUTER_PRESETSautorouter_presets.json bundled in the image
What's new feedSPANWAY_WHATS_NEW_URLSPANWAY_LOCAL_WHATS_NEWwhats_new.json bundled in the image
Policy templatesnone, fixed URL on the docs siteSPANWAY_LOCAL_POLICY_TEMPLATESpolicy_templates_backup.json bundled in the image
Release checkSPANWAY_RELEASE_CHECK_URLnone, opt-in through the URLReported as unavailable, the Admin UI upgrade banner stays hidden
Breached-password checknone, fixed URL on api.pwnedpasswords.compassword_policy_check_breached_passwords: false in general_settingsSkipped, new and changed passwords are checked against the strength policy only
Hugging Face tokenizersnone, fixed repositories on huggingface.codisable_hf_tokenizer_download: true in spanway_settings, which also drops the Anthropic tokenizer and does not cover custom tokenizersCohere, Llama and custom tokenizers count with tiktoken, the bundled Anthropic tokenizer is kept
Hugging Face model configsnone, config.json on huggingface.cononeThe context window of a huggingface/ model that is missing from the price map is reported as unknown

The release check is skipped even when SPANWAY_RELEASE_CHECK_URL is set, so you can keep the variable in a shared config without a stray request from the air-gapped environment.

A model with a custom_tokenizer in its model_info is the one case that logs a warning, once per tokenizer, because its token counts change from the configured tokenizer to tiktoken.

One other lookup on huggingface.co is not covered by the switch yet. The gateway fetches tokenizer_config.json to find the chat template for providers that build prompts from a Hugging Face template. On an air-gapped gateway this request fails, and the missing template can fail the request.

Egress allowlist​

SPANWAY_AIRGAPPED stops the optional fetches, but provider calls, caches, logging callbacks and secret managers still connect wherever they are configured. To make the gateway itself refuse any destination you did not approve, list the hosts it may reach in general_settings.egress_allowlist.

general_settings:
egress_allowlist:
- api.openai.com
- "*.openai.azure.com"
- bedrock-runtime.us-east-1.amazonaws.com
- redis.internal.example.com
- 10.20.0.0/16

Each entry is an exact hostname, a *. wildcard that matches any subdomain (but not the bare domain), or an IP address or CIDR range. Loopback is always allowed. When the setting is present the gateway checks every name it resolves, from any client in the process, including the provider SDKs, the fetches in the table above, and your logging callbacks. A host outside the list fails with a connection error that says it is not in the egress allowlist, before any DNS query leaves the machine. An empty list allows loopback only.

The check is installed once at startup and cannot be turned off without restarting the process, so a value that does not parse as a list of strings stops the proxy from starting instead of running without it. Changing the list needs a restart.

The list can also be edited in the Admin UI under Settings > Admin Settings > Security Settings, in the Network allowlists card as Egress allowlist, one entry per line, with [] meaning loopback only. A list saved there is stored in the database and each gateway applies it the first time it reads its settings from the database after starting, within proxy_config_reload_interval_seconds (30 seconds by default). A gateway that was already running when you saved keeps its old list until it restarts, so restart every gateway after saving. When config.yaml already sets the list, the field is shown as Set in config file and has to be changed in the file.

There are limits worth knowing. The check runs on name resolution, so a client that connects straight to an IP address without resolving it first (aiohttp and asyncio do this for IP literals) is not stopped by a hostname entry. The Prisma query engine and the Rust native extension run outside the Python interpreter and are not covered either. Keep a network policy or firewall egress rule as the outer boundary and treat this setting as the layer that catches misconfiguration and unexpected calls inside the gateway.

Confirming the mode from outside​

/health/readiness reports the mode, so a probe or a human can check it without reading the logs or the environment of the pod.

curl -s http://localhost:4000/health/readiness
{"status": "healthy", "db": "connected", "airgapped": true, "coordination_redis": "not_configured"}

The authenticated /health/readiness/details payload carries the same airgapped field.

Mirroring the container images​

The gateway ships from Spanway's registry as registry.spanway.ai/spanway/spanway-ai. Everywhere this page writes registry.spanway.ai is the one address an air-gapped or mirror install replaces with its own registry host, and registry.internal below stands for that host. Pull the tag you want on a connected machine, retag it for your registry, push it, and point your deployment at the mirror. Pin a version rather than latest so the air-gapped side never depends on what a tag pointed to on a given day.

VERSION=2.0.0
docker pull registry.spanway.ai/spanway/spanway-ai:$VERSION
docker tag registry.spanway.ai/spanway/spanway-ai:$VERSION registry.internal/spanway/spanway-ai:$VERSION
docker push registry.internal/spanway/spanway-ai:$VERSION

If the two networks are physically separated, carry the image across as a tarball.

docker save registry.spanway.ai/spanway/spanway-ai:$VERSION | gzip > spanway-ai-$VERSION.tar.gz
# on the air-gapped side
gunzip -c spanway-ai-$VERSION.tar.gz | docker load
docker tag registry.spanway.ai/spanway/spanway-ai:$VERSION registry.internal/spanway/spanway-ai:$VERSION
docker push registry.internal/spanway/spanway-ai:$VERSION

The image bundles the Prisma CLI and the query and migration engines under /opt/prisma and sets PRISMA_OFFLINE_MODE=true, so the schema migrations that run at boot need no download. You do not need a Node.js registry or the Prisma binary mirror reachable from the pod.

Mirroring the Helm chart​

The chart is published as an OCI artifact next to the image. Pull it on the connected side, push it to your registry, and install from there. The Lens, Postgres and Redis subcharts are packed into the chart archive, so a single helm pull is enough. The chart version always equals the gateway version, so the commands reuse $VERSION from the image steps above.

CHART_VERSION=$VERSION
helm pull oci://registry.spanway.ai/spanway/charts/spanway-helm --version $CHART_VERSION
helm push spanway-helm-$CHART_VERSION.tgz oci://registry.internal/charts

Install with the image repository and the switch overridden.

helm install spanway oci://registry.internal/charts/spanway-helm --version $CHART_VERSION \
--set image.repository=registry.internal/spanway/spanway-ai \
--set image.tag=$VERSION \
--set envVars.SPANWAY_AIRGAPPED=true

The chart deploys a standalone Postgres by default (db.deployStandalone) and can deploy Redis (redis.enabled). If you keep either, mirror the images listed under postgresql.image and redis.image in values.yaml as well and override those repositories the same way. Most air-gapped installs set db.useExisting and point the chart at a database the platform team already runs instead.

Refreshing the model price map offline​

With the switch on, the gateway prices requests from the model_prices_and_context_window_backup.json that shipped in the image. Newer models and price changes arrive with each release, so upgrading the image is the simplest refresh. When you need a newer map between releases, the loader also accepts a file:// URL, which is read from disk with the same integrity checks as a remote fetch and never touches the network.

  1. On a connected machine, download the current map and carry it across.

    curl -fsSL https://docs.spanway.ai/data/model_prices_and_context_window.json -o model_prices_and_context_window.json
  2. Mount the file into the container, for example at /etc/spanway/model_prices_and_context_window.json.

  3. Point the loader at it and turn off the local-only override for this one fetch. SPANWAY_AIRGAPPED and SPANWAY_LOCAL_MODEL_COST_MAP both force the bundled copy, so leave them unset on a gateway that reads the mirrored file and rely on the per-fetch switches for the rest.

    export SPANWAY_MODEL_COST_MAP_URL=file:///etc/spanway/model_prices_and_context_window.json
    export SPANWAY_LOCAL_BLOG_POSTS=true
    export SPANWAY_LOCAL_ANTHROPIC_BETA_HEADERS=true
    export SPANWAY_LOCAL_AUTOROUTER_PRESETS=true
    export SPANWAY_LOCAL_WHATS_NEW=true
    export SPANWAY_LOCAL_POLICY_TEMPLATES=true
  4. Confirm which map is loaded. The url is the file URL and source is remote, meaning the configured URL rather than the bundled backup.

    curl -s http://localhost:4000/model/cost_map/source -H "Authorization: Bearer $SPANWAY_MASTER_KEY"

    This route is an operator check and is not part of the published API reference.

If the file is missing or malformed, the loader logs a warning and falls back to the bundled map, exactly as it would for an unreachable remote URL. Replacing the file and triggering a reload, or restarting the gateway, picks up the new copy.

Checklist​

  1. Set SPANWAY_AIRGAPPED=true in the gateway environment, or under envVars in the Helm values.
  2. Mirror registry.spanway.ai/spanway/spanway-ai at a pinned version and override image.repository and image.tag.
  3. Mirror the spanway-helm chart into your OCI registry.
  4. Mirror the bundled Postgres and Redis images only if you use them, otherwise point the chart at your own.
  5. Confirm /health/readiness returns "airgapped": true after rollout.
  6. Decide how you refresh prices, by upgrading the image or by mirroring model_prices_and_context_window.json behind a file:// URL.
  7. Check the gateway log for warnings about failed fetches. There should be none apart from the custom tokenizer warning and the two huggingface.co lookups described above, since every fetch in the table is skipped.

Errors​

What you seeWhat it meansFix
"airgapped": falseThe variable is not set in the gateway container, or it holds another value than true, 1 or yes.Set it and restart.
Image pulls failThe deployment still points at the public registry.Override image.repository and image.tag with your mirror.
New models have no priceThe bundled price map is older than the model.Upgrade the image, or mirror the price map behind a file:// URL as shown above.
A tokenizer warning at startupA custom tokenizer needs a download that the mode blocks.Expected, see What the switch covers.
A call fails with Outbound connection to <host> refused, it is not in the egress allowlistThe gateway tried to reach a host that egress_allowlist does not list. Provider calls surface it as a connection error, usually a 500 or 503 to the caller.Add the host, a *. wildcard or its CIDR range to egress_allowlist and restart.
The gateway stops at startup with a validation error that names egress_allowlistThe value in config.yaml is not a list of strings, for example a single hostname without the list dash.Write it as a YAML list, one entry per line.

Logs​

LevelLineMeaningAction needed
INFOSpanway: SPANWAY_AIRGAPPED is set, optional outbound fetches use their bundled fallbacksThe mode is on. Shown only with SPANWAY_LOG=INFO or lower.None.
ERRORegress_allowlist in the database is not a list of hosts and was not appliedThe list saved in the database cannot be read, so the gateway runs without it.Save the list again from the Network allowlists card, or set it in config.yaml.
WARNINGA failed fetch of one of the URLs in the table aboveA per-fetch switch is not on and the mode is off, so the gateway tried the network and fell back to its bundled copy.Turn the mode on, or the fetch's own switch.