Skip to content

Multiple tenants

One xixo serves one catalog, named by XIXO_TENANT. It can serve several. Each one is a tenant: a separate catalog with its own resources, feeds, analyses, runs, settings, and audit trail, at its own host. Every request and every job runs inside exactly one tenant. Nothing in the catalog, the index, or the browser app is shared between tenants.

The self-hosting guide sets up one tenant. This page says what changes with several.

A deployment declares its tenants in one of two ways. Setting both stops xixo:tenants with Tenant::TenancyConflict, and the container exits.

Declared by A request resolves by
Single XIXO_TENANT=xixo Nothing. Every host is that tenant.
Multi XIXO_TENANTS=demo,acme The first label of the host name. demo.xixo.example.com is demo.

The container entrypoint runs bin/rails xixo:tenants on boot, which creates each declared tenant that does not exist, in xixo and in the built-in masks, and then bin/rails xixo:resources, which declares the resources in config/resources.yml in every tenant. A request resolves against the tenants in the database, so removing a name from XIXO_TENANTS neither deletes that tenant nor stops xixo from serving it. A host that names no tenant gets 404 Unknown tenant. The health check at /up is the only path served outside a tenant.

  1. Set XIXO_TENANTS to the tenants’ names, separated by commas.

  2. Set XIXO_HOST_SUFFIX to the domain the tenants answer under, such as xixo.example.com. Rails answers 403 to a Host outside it, except at /up.

  3. Set XIXO_PUBLIC_ORIGIN with %{subdomain} standing for the tenant’s name:

    Terminal window
    XIXO_PUBLIC_ORIGIN=https://%{subdomain}.xixo.example.com
  4. Point DNS for each tenant’s host, or a wildcard under the suffix, at the reverse proxy, and send every host to xixo:

    *.xixo.example.com {
    reverse_proxy xixo:80
    }

The proxy must pass the original Host header, because xixo finds the tenant from the host. To add a tenant later, add it to XIXO_TENANTS and recreate the web container.

Each xixo tenant is a client of a masks tenant with the same name. With the built-in masks, each tenant signs in at /id on its own origin, so demo.xixo.example.com signs in at demo.xixo.example.com/id. xixo:tenants prints a setup token for each masks tenant that has no account yet, and the first sign-in at each tenant goes as the self-hosting guide describes.

With a masks server of your own, %{subdomain} in MASKS_ISSUER_TEMPLATE names the masks tenant each xixo tenant signs in through:

Terminal window
MASKS_ISSUER_TEMPLATE=https://%{subdomain}.auth.example.com

A token is accepted only at the tenant it was issued for. Its issuer must be that tenant’s issuer, its audience that tenant’s origin followed by /mcp, and any tenant claim it carries must name that tenant. A token whose tenant claim names acme is refused at demo. See tokens.

xixo link beside the server serves one tenant. Run one link container for each tenant, each with its own state volume and these settings:

XIXO_LINK_XIXO The tenant’s origin, such as https://acme.xixo.example.com.
XIXO_LINK_ISSUER The tenant’s masks issuer, the origin followed by /id with the built-in masks.
XIXO_LINK_HANDOFF /handoff/<tenant>, in the volume the web and worker containers mount at XIXO_LOCAL_LINK.
XIXO_LINK_WRITABLE /data/files/<tenant>, where config/resources.yml puts the tenant’s Files resource.

Each one enrolls itself after the first sign-in connects its tenant to masks, as xixo link beside the server describes.

Isolation has two layers:

Layer What it does
Default scope Every tenant model is scoped to the current tenant, and new rows take its id.
Row-level security Every tenant table has FORCE ROW LEVEL SECURITY and a tenant_isolation policy.

The policy compares each row’s tenant_id with the tenant the database session is in, for reads and writes. Outside a tenant the policy matches no rows, so code that skips the default scope still finds nothing from another tenant. Active Storage’s tables carry the same policy, so a signed blob id from one tenant finds no row in another.

A Postgres role with SUPERUSER or BYPASSRLS ignores every policy. xixo checks its role the first time a process enters a tenant, and raises Tenant::Exposed if the role can bypass the policies. See the database role.

Every job records the tenant it was enqueued in and runs inside it. A job enqueued outside a tenant raises an error. All tenants share one OpenSearch index, and each searches through a filtered alias of its own. See search.

  • ANALYSIS_PER_TENANT, 2 by default, is how many analyses one tenant may run at the same time across every process, so one tenant cannot fill the pool.
  • XIXO_MCP_LIMIT and XIXO_RUN_BUDGET count per tenant. See budgets and gates.
  • XIXO_ITERATORS_DISABLED=true stops every sync, analysis, export, and reindex in every tenant.
  • Mission Control at /jobs would list every tenant’s jobs, because Solid Queue’s tables sit outside row-level security. xixo sets no user or password for it, so it answers 401. Leave it closed, or block /jobs at the proxy.
  • Settings > Updates belongs to one tenant. Set XIXO_UPDATES_TENANT to its name, and its administrators see and control the server’s updates. Without it, no one controls them from xixo. See keep xixo up to date.
  • Every page answers 404 Unknown tenant: neither XIXO_TENANT nor XIXO_TENANTS is set, or the host’s first label names no declared tenant.
  • Tenant::TenancyConflict: both XIXO_TENANT and XIXO_TENANTS are set. Remove one.
  • A token works at one tenant and is refused at another: that is by design. Each MCP client and each browser session belongs to the tenant that issued its token.
  • Only one tenant’s xixo link shows as This server: each tenant needs a link container of its own, with its own XIXO_LINK_HANDOFF folder and state volume.