High availability¶
A single BastionXP server, with its built-in SQLite database, is enough for small teams and for tests.
For production, we recommend running several BastionXP servers behind a load balancer. If one server fails, the others keep serving. All the servers share one PostgreSQL database and one Redis server:
PostgreSQL¶
To use PostgreSQL, add a database section to the configuration file:
database:
driver: postgres
hostname: db.example.com
port: "5432"
db_name: bastionxp
user: bastionxp
password: change-this-password
ssl_mode: verify-full
| Setting | What it means |
|---|---|
driver |
postgres for PostgreSQL. Any other value, or no database section, means SQLite. |
hostname, port, db_name, user, password |
Where the PostgreSQL server is, and how to log in to it. Write the port in quotes. |
ssl_mode |
How the connection is encrypted and checked. These are PostgreSQL's own values: disable, require, verify-ca or verify-full. Use verify-full in production. |
Create the empty database before you start BastionXP. BastionXP creates its tables.
With SQLite, the database is a file in BastionXP's data directory, /var/lib/bastionxp. Only one server can use it.
Redis¶
To use Redis, add a redis section to the configuration file:
| Setting | What it means |
|---|---|
addr |
The address of the Redis server, as host:port. |
password |
The Redis password, if it needs one. |
db |
The Redis database number. The default is 0. |
tls |
Set it to true to encrypt the connection. Use it, if Redis is not on a private network. |
With Redis, the servers share four things that each server otherwise keeps for itself:
| What is shared | With Redis | Without Redis |
|---|---|---|
| ACME nonces | An ACME client can send each request to any server. | Each server knows only its own nonces. Behind a load balancer, ACME clients then fail with the error badNonce. |
| Portal sessions | An administrator stays signed in, whichever server answers. | The session is kept in a signed cookie in the browser. |
| Rate limits | One limit counts the requests to all the servers together. | Each server counts only its own requests. |
| Sign-in attempts per address | The limit on sign-in attempts from one network address counts the attempts on all the servers together. | Each server counts only its own attempts. |
Redis holds only temporary data. If you lose it, nobody loses a certificate or a setting.
One configuration for all the servers¶
You change authorities, verifiers, certificate profiles and settings in the web portal, on any one server. BastionXP keeps them in the shared database, so there is nothing to copy to the other servers.
When you save a change, the other servers pick it up by themselves, without a restart. With Redis, the server that took the change sends a notice, and the others reload at once. Every server also checks the database every 5 seconds, in case a notice was lost. So a change reaches every server within a few seconds, with or without Redis.
The configuration file holds only what a server needs before it can reach its database, such as the database address and the KEK. Keep it the same on every server.
What every server needs¶
Every BastionXP server behind the load balancer needs:
- The same configuration file,
/etc/bastionxp/config.yaml. - A server certificate for the name that clients use. Put it in each server's data directory, as
server.crtandserver.key. Use the same certificate on every server. If your load balancer handles HTTPS, use the load balancer's certificate instead. - The same key-encryption key (KEK). The KEK encrypts the keys in the database, so every server must have the same one. A server with a different KEK does not start. See Key protection.
- The same HSM or KMS, if the CA keys are kept in one. See Key protection. For an HSM, set
max_sessionsso that all the servers together stay below the HSM's session limit.
The key that signs the portal's sessions is kept in the shared database, encrypted with the KEK. You do not have to copy it.
The load balancer's health check¶
Point the health check of your load balancer at https://<server>/health. A server answers 200 when it can reach its database, and Redis if you use it. It answers 503 when it cannot, so that the load balancer stops sending it requests. See Monitoring.
The load balancer must also pass TCP port 80 to the servers. It carries the CRLs, the OCSP responder and the CA certificates. See Why BastionXP also listens on HTTP.
Back up¶
Back up the database, the configuration file and the KEK. See Backup and restore.
To limit how many certificate requests each authority and verifier accepts, see Rate limits.