Install¶
How-to guideThe steps for one task.
Apinx is one static binary that serves the gateway, the Admin API and the console. On a server it runs under systemd on Linux; that is the supported way to run it in production. Container images are not supported at the moment.
Before you start¶
The server. A single node needs 2 CPU cores and 4 GB of RAM to start; add cores before memory as traffic grows, since the hot path is CPU-bound. Use Ubuntu 24.04 LTS or Debian 12. Apinx also runs on Windows and macOS, which is fine for trying it out, but production is supported on Linux: that is where it is operated and tested under load.
What you receive from MoznHub.
| File | What it is |
|---|---|
apinx-linux-amd64 (or -arm64) |
The gateway, Admin API and console in one binary |
apinxctl-linux-amd64 (or -arm64) |
The command-line client for the Admin API |
SHA256SUMS |
Checksums: sha256sum --check --ignore-missing SHA256SUMS must print OK |
deploy/systemd/ |
The systemd unit, an example process configuration and the log rotation |
configs/gateway.example.yaml |
The first gateway configuration (a listener) |
deploy/grafana/ |
A Grafana dashboard for the access log in Loki (Grafana and other tools) |
apinx.lic |
Your licence. Without one, an installation runs a 30-day evaluation with every feature |
Run the commands below from the folder you unpacked them into.
Two hostnames. One for the console (console.example.com), one for the APIs you publish
(api.example.com). Keeping them apart lets you restrict the console without touching API
traffic.
The production install¶
Deploying on Linux is the complete recipe, step by step: the service user and binaries, the process configuration, the hardened systemd unit, PostgreSQL, the master key, nginx with TLS for both names, the firewall, the first administrator, the licence, upgrades and removal. For two or more servers, follow it on each and then High availability.
The short version¶
One server, SQLite files, the console reached through an SSH tunnel until you put nginx in front:
sha256sum --check --ignore-missing SHA256SUMS
sudo useradd --system --home /var/lib/apinx --shell /usr/sbin/nologin apinx
sudo install -m 0755 apinx-linux-amd64 /usr/local/bin/apinx
sudo install -m 0755 apinxctl-linux-amd64 /usr/local/bin/apinxctl
sudo mkdir -p /etc/apinx
sudo cp deploy/systemd/apinx.yaml /etc/apinx/apinx.yaml
sudo cp configs/gateway.example.yaml /etc/apinx/gateway.yaml
echo "APINX_SECURITY_MASTER_KEY=$(openssl rand -base64 32)" | sudo tee /etc/apinx/apinx.env
sudo chmod 0600 /etc/apinx/apinx.env # the master key: keep a copy in your password manager
sudo cp deploy/systemd/apinx.service /etc/systemd/system/
sudo cp deploy/systemd/apinx.logrotate /etc/logrotate.d/apinx
sudo systemctl daemon-reload && sudo systemctl enable --now apinx
journalctl -u apinx -f # the claim token is printed here on first start
The unit runs as the apinx user with a read-only system, creates /var/lib/apinx (data) and
/var/lib/apinx-keys (a generated development key, unused once apinx.env sets one), can
bind ports 80 and 443 without root, and drains in-flight requests on stop. The console listens
on 127.0.0.1:9000 in that configuration: reach it with ssh -L 9000:127.0.0.1:9000 you@server
and open http://localhost:9000. Behind a TLS proxy, set console.public_url to the address
users open (https://console.example.com): the session cookies become Secure and
identity-provider redirects use that address.
Every setting has an environment variable (APINX_<SECTION>_<KEY>) and a flag; see the
process configuration reference.
PostgreSQL instead of files¶
SQLite is the default and needs nothing installed. A server install usually wants PostgreSQL
14 or later, for backups and tooling you already have: put the connection in apinx.env.
APINX_STORAGE_DRIVER=postgres
APINX_STORAGE_DSN=postgres://apinx:<password>@127.0.0.1:5432/apinx?sslmode=disable
Tables are created on first start and migrated on upgrades. The gateway's request path never touches the database, so the choice has no effect on latency; it decides where backups live, and it is required to run several instances (High availability).
The master key¶
Stored secrets (API key material, backend credentials, JWT secrets, identity-provider client secrets) are encrypted with a master key. Without configuration a key is generated on first start and the console warns until you configure an external one:
| Provider | Setting | Use |
|---|---|---|
| Environment variable | APINX_SECURITY_MASTER_KEY (32 bytes, base64) |
Most deployments; the recommended default |
| File | security.master_key_file |
systemd credentials, mounted secrets |
| Vault | security.master_key_provider: vault and security.vault.* |
Vault Transit |
| Command | security.master_key_provider: command |
Any KMS CLI |
Generate one with openssl rand -base64 32. To move from the generated key to an external one,
set the new key and name the old file as security.previous_master_key_file for one start; the
data keys are re-wrapped and the old file can be deleted.
A backup is the database plus the master key
Restoring the database without the key that encrypted its secrets leaves them unreadable, by design. Keep the key where you keep other production secrets, apart from the backups.
The licence¶
Paste the licence in Admin › About › Install licence, or put the file at
/etc/apinx/apinx.lic and set APINX_LICENSE_FILE=/etc/apinx/apinx.lic in apinx.env. It is
verified on the server, offline; nothing is sent anywhere. Until a licence is installed the
console shows the evaluation's days left; after them, deployed APIs keep serving traffic and
the console becomes read-only. See Licensing.
First start checklist¶
- [ ] The checksums matched (
sha256sum --check). - [ ] Port 9000 (console and Admin API) is on the loopback interface or behind TLS, never on
the same public address as the APIs. Behind TLS,
console.public_urlis the https address. - [ ] The claim token from the first start was used to create the administrator.
- [ ]
APINX_SECURITY_MASTER_KEYis set and a copy is in your password manager. - [ ] The licence is installed; Admin › About shows your company.
- [ ]
/readyzanswers 200.