---
title: SQLite / Postgres
description: >-
  Like Redis, SQLite and Postgres can store certificates, ACME challenges and
  routes, shared by every Super instance using the same database.
---
> ## Documentation Index
> Fetch the complete documentation index at: https://docs.page/luizfonseca/super/llms.txt
> Use this file to discover all available pages before exploring further.

Like [Redis](/configuration/redis), SQLite and Postgres can store certificates, ACME challenges and routes, shared by every Super instance using the same database.

These stores are optional and need Super to be built with the `store-sqlite` and/or `store-postgres` cargo features:

```bash
cargo install --git https://github.com/luizfonseca/super super_proxy --features store-sqlite,store-postgres
```

## Configuration

**config.hcl**
```hcl
store {
  store_type = "postgres" # or "sqlite"
  database_url = "postgres://user:password@localhost:5432/proksi"
  # database_url = "sqlite:///var/lib/proksi/proksi.db?mode=rwc"

  # How often (in seconds) routes are synced from the store (default: 10)
  sync_interval_secs = 10

  # Versions kept for each host, to roll back to (default: 50)
  history_per_host = 50
}
```

Super creates (and updates) its tables on startup. For SQLite, `?mode=rwc` creates the database file if it doesn't exist.

## Routes

Routes are stored in the `proksi_routes` table, one row per host (lowercase), with the route in the `data` column as JSON:

```json
{ "schema_version": 1, "route": { "host": "example.com", "upstreams": [{ "ip": "10.0.0.1", "port": 3000 }] } }
```

The `route` has the same format as a route in the configuration file. Every change must increment the revision in the same transaction, otherwise instances won't see it:

```sql
BEGIN;
INSERT INTO proksi_routes (host, schema_version, data, updated_at)
VALUES ('example.com', 1, '{"schema_version":1,"route":{...}}', 0)
ON CONFLICT (host) DO UPDATE SET data = excluded.data, updated_at = excluded.updated_at;
UPDATE proksi_meta SET value = value + 1 WHERE key = 'revision';
COMMIT;
```

Hosts saved through the [admin API](/configuration/admin) also keep their last versions (`history_per_host`) and changes, in `proksi_route_versions` and `proksi_route_changes`, so a host can be rolled back. Changes written directly to `proksi_routes`, as above, aren't recorded there.

Each instance reports the revision it applied in `proksi_replicas`. As with Redis, routes from the store win over docker labels and the configuration file, and the routes from the last sync are kept if the database can't be reached.

Let's Encrypt data (account, certificates and challenges) is stored in the database too, so all instances share the same account.

As with [Redis](/configuration/redis#certificates-with-several-instances), instances order each certificate once (through a lease in `proksi_locks`), and a certificate written by one instance reaches the others within `sync_interval_secs`.

[Waiting rooms](/plugins/waiting-room) are shared too, in `proksi_waiting_rooms` and `proksi_waiting_room_visitors`, with their cookies' key in `proksi_keys`.
