Skip to main content

Deploying OpenBao Open-Source Secrets Management Platform

Deploy OpenBao with Docker Compose, Raft storage, and Traefik HTTPS, then manage secrets with policies, userpass auth, the CLI, and the HTTP API.

Updated 12 min readMarkdown
Part of seriesThe Self-Hosted Stack
Deploying OpenBao Open-Source Secrets Management Platform

OpenBao is an open-source secrets management platform that stores, generates, and controls access to credentials, certificates, and encryption keys. It began as a community fork of HashiCorp Vault and is governed by the Linux Foundation under the Mozilla Public License 2.0 (MPL-2.0), exposing an HTTP API, a CLI, and a web interface that share the same authentication model. This guide installs OpenBao with Docker Compose on a Linux server, configures the Raft integrated storage backend, deploys it behind a Traefik reverse proxy with automatic TLS certificates, initializes and unseals the server, and sets up the key-value version 2 secrets engine with an access control policy and a user account. By the end, you'll have a self-hosted OpenBao instance where applications store and retrieve secrets through the CLI and the HTTPS API with scoped tokens, following secrets management deployment practices documented in Vultr Docs.


Prerequisites


Set Up the Directory Structure, Configuration, and Environment Variables

OpenBao reads its runtime settings from a HashiCorp Configuration Language (HCL) file that declares the network listener, the storage backend, and the cluster addresses. The Raft integrated storage backend writes encrypted data to a local directory, which removes the need for an external database.

1. Create the project directory along with a configuration subdirectory:

mkdir -p ~/openbao/config

2. Switch to the project directory:

cd ~/openbao

3. Create the OpenBao server configuration file:

nano config/config.hcl

4. Add the following Raft storage configuration. Replace bao.example.com with your domain name:

ui = true

storage "raft" {
  path    = "/openbao/file"
  node_id = "openbao-node-1"
}

listener "tcp" {
  address     = "0.0.0.0:8200"
  tls_disable = true
}

audit "file" "app-audit" {
  description = "Records every request and response to the mounted logs volume."
  options {
    file_path = "/openbao/logs/audit.log"
  }
}

api_addr     = "https://bao.example.com"
cluster_addr = "https://openbao:8201"

The configuration declares the following settings:

  • ui: Enables the built-in web interface at the /ui path.
  • storage "raft": Selects the integrated storage backend. The path value matches the data directory inside the container, and node_id identifies the node within the Raft cluster.
  • listener "tcp": Binds the API to all container interfaces on port 8200. TLS terminates at Traefik, so the listener serves plain HTTP on the private Docker network and is never published to the host.
  • audit "file": Declares a file audit device that records every request and response to the mounted logs volume. Declaring the device in the configuration file activates auditing from the first boot.
  • api_addr: The external URL OpenBao advertises to clients for request redirection.
  • cluster_addr: The internal address used for server-to-server communication on port 8201.

5. Create the environment file:

nano .env

6. Add the following variables. Replace bao.example.com with the domain that resolves to your server, and ADMIN_EMAIL with a deliverable address on a domain you control, because Let's Encrypt rejects addresses on reserved domains such as example.com:

BAO_DOMAIN=bao.example.com
ACME_EMAIL=ADMIN_EMAIL

Deploy with Docker Compose

The deployment runs two containers on a shared bridge network. Traefik accepts external traffic on ports 80 and 443, requests a Let's Encrypt certificate through the TLS-ALPN challenge, and forwards decrypted requests to the OpenBao container on port 8200. Named volumes preserve the Raft database and audit logs across container replacements.

1. Create the Compose file:

nano docker-compose.yml

2. Add the following configuration:

services:
  openbao:
    image: openbao/openbao:2.6.1
    container_name: openbao
    restart: unless-stopped
    command: server
    environment:
      BAO_ADDR: http://127.0.0.1:8200
    volumes:
      - ./config:/openbao/config:ro
      - openbao-data:/openbao/file
      - openbao-logs:/openbao/logs
    networks:
      - openbao-network
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.openbao.rule=Host(`${BAO_DOMAIN}`)"
      - "traefik.http.routers.openbao.entrypoints=websecure"
      - "traefik.http.routers.openbao.tls.certresolver=letsencrypt"
      - "traefik.http.services.openbao.loadbalancer.server.port=8200"

  traefik:
    image: traefik:v3.7.10
    container_name: traefik
    restart: unless-stopped
    command:
      - "--providers.docker=true"
      - "--providers.docker.exposedbydefault=false"
      - "--entrypoints.web.address=:80"
      - "--entrypoints.web.http.redirections.entrypoint.to=websecure"
      - "--entrypoints.web.http.redirections.entrypoint.scheme=https"
      - "--entrypoints.websecure.address=:443"
      - "--certificatesresolvers.letsencrypt.acme.email=${ACME_EMAIL}"
      - "--certificatesresolvers.letsencrypt.acme.storage=/letsencrypt/acme.json"
      - "--certificatesresolvers.letsencrypt.acme.tlschallenge=true"
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - ./letsencrypt:/letsencrypt
    networks:
      - openbao-network

volumes:
  openbao-data:
  openbao-logs:

networks:
  openbao-network:
    driver: bridge

In this configuration:

  • command: Overrides the image default, which starts a throwaway development server, and launches a production server instead. The entrypoint loads every configuration file in /openbao/config.
  • BAO_ADDR: Points the CLI inside the container at the local listener, so administrative commands run without an address flag.
  • ./config:/openbao/config:ro: Mounts the configuration directory read-only.
  • openbao-data: Stores the Raft database that holds every encrypted secret. Deleting this volume destroys the deployment data.
  • labels: Registers the container with Traefik, matches requests for the configured host, and enables certificate issuance through the letsencrypt resolver.
  • exposedbydefault=false: Routes only containers that explicitly set traefik.enable=true.

3. Start the stack in detached mode:

docker compose up -d

4. Verify that both containers are running:

docker compose ps

The output displays two running containers with Traefik listening on ports 80 and 443.

5. Inspect the OpenBao logs to verify that the server started:

docker compose logs openbao

The output displays a configuration summary followed by a message confirming that the server started. The log may begin with chown: /openbao/config: Read-only file system warnings. These are expected because the configuration directory is mounted read-only, and they do not affect the server.

6. Verify that Traefik issued a certificate and routes traffic to OpenBao. Replace bao.example.com with your domain name:

curl -I https://bao.example.com/v1/sys/health

The response returns an HTTP 501 status, which OpenBao uses to report an uninitialized server, and curl raises no certificate error. Certificate issuance takes up to a minute after the containers start. A certificate error or a connection timeout indicates that the domain does not resolve to the server or that inbound traffic on ports 80 and 443 is blocked.


Access and Configure OpenBao

A newly deployed server is both uninitialized and sealed. Initialization generates the root encryption key, splits it into Shamir key shares, and returns the initial root token. The server decrypts its storage only after an operator supplies a threshold number of shares.

1. Initialize the server with three key shares and an unseal threshold of two:

docker compose exec openbao bao operator init -key-shares=3 -key-threshold=2

The output resembles the following:

Unseal Key 1: JQ3UVC11z8zCI1k0j1cg/M2TkGbTS/RYiCmxedDGNu/E
Unseal Key 2: Bv9HCpu1Fv44cWY1/i9YCQvXODnC+N53g2XPG/1tL5tf
Unseal Key 3: 2F4cilGWdHyEbxxTPpTjgWe8mt+e13s3NBM7S3Flbr4Z

Initial Root Token: s.B1xwAeU4gFHAhSIjGF7C3xZS

Vault initialized with 3 key shares and a key threshold of 2. Please securely
distribute the key shares printed above. When the Vault is re-sealed,
restarted, or stopped, you must supply at least 2 of these keys to unseal it
before it can start servicing requests.
...

OpenBao inherits several user-facing strings from its Vault origin, so the message refers to Vault.

Warning: Store the unseal keys and the root token in separate secure locations outside the server. OpenBao does not store them, and losing a threshold number of shares permanently locks the encrypted data. Distribute individual key shares to different operators so that no single person can unseal the server alone.

2. Supply the first unseal key. Replace UNSEAL_KEY_1 with the first key from the initialization output:

docker compose exec openbao bao operator unseal UNSEAL_KEY_1

The output reports Sealed as true and an unseal progress of 1/2.

3. Supply the second unseal key. Replace UNSEAL_KEY_2 with the second key:

docker compose exec openbao bao operator unseal UNSEAL_KEY_2

The output reports Sealed as false, confirming the server is ready to serve requests. The HA Mode field reads standby for a few seconds while the node completes leader election, then reads active.

The server starts sealed after every container restart. Production deployments avoid this manual unseal with an auto-unseal seal stanza backed by a cloud Key Management Service (KMS) or a second OpenBao instance running the Transit engine.

4. Authenticate with the initial root token. Replace ROOT_TOKEN with the token from the initialization output:

docker compose exec openbao bao login ROOT_TOKEN

The output confirms that the token is stored and lists its attached policies, root among them.

5. Enable the key-value version 2 secrets engine at the kv path:

docker compose exec openbao bao secrets enable -path=kv kv-v2

The output confirms that the engine is enabled at kv/. Version 2 retains a configurable history of every secret, which allows rollbacks and soft deletion.

6. Verify that the audit device declared in the configuration file is active:

docker compose exec openbao bao audit list

The output lists the app-audit/ device with type file. OpenBao writes one structured JSON entry per request and response, with sensitive values replaced by HMAC digests.

7. Create an access control policy file in the project directory:

nano app-policy.hcl

8. Add the following policy:

path "kv/data/app/*" {
  capabilities = ["create", "read", "update", "delete", "list"]
}

path "kv/metadata/app/*" {
  capabilities = ["read", "list", "delete"]
}

The policy grants access only to secrets under the app/ prefix. The kv/data/ path controls the secret values, while kv/metadata/ controls version history and deletion metadata. OpenBao denies every path that a policy does not explicitly allow.

9. Write the policy to the server:

docker compose exec -T openbao bao policy write app-policy - < app-policy.hcl

The - argument reads the policy from standard input, which keeps the file out of the mounted configuration directory. The output confirms that OpenBao uploaded the app-policy policy.

10. Enable the userpass authentication method:

docker compose exec openbao bao auth enable userpass

The output confirms Success! Enabled userpass auth method at: userpass/. Accounts under this method authenticate with a username and password and receive a token scoped to the attached policies.

11. Create a user account bound to the policy. Replace STRONG_PASSWORD with a strong password:

docker compose exec openbao bao write auth/userpass/users/appuser \
    password=STRONG_PASSWORD \
    token_policies=app-policy

Tokens issued to this account inherit app-policy and cannot read secrets outside the app/ prefix. Each token expires after the default lease duration of 768 hours.

12. Sign in to the web interface. Open https://bao.example.com in a web browser, replacing bao.example.com with your domain name. Select Username as the authentication method, then enter appuser and the password. The interface displays the secrets engines that the token can access.


Manage Secrets Through the CLI and API

A complete secret lifecycle spans an operator write through the CLI and an application read over the HTTPS API with a token scoped to the appuser account.

Store a Secret via CLI

The bao kv command group writes and reads structured secrets. Each write creates a new version rather than overwriting the previous value.

1. Write a database credential to the app/database path. Replace DB_PASSWORD with the actual database password:

docker compose exec openbao bao kv put kv/app/database \
    username=app_admin \
    password=DB_PASSWORD

The output confirms the write and reports version 1.

2. Read the secret back:

docker compose exec openbao bao kv get kv/app/database

The output resembles the following:

==== Secret Path ====
kv/data/app/database

======= Metadata =======
Key                Value
---                -----
created_time       2026-08-09T19:51:37.543247332Z
custom_metadata    <nil>
deletion_time      n/a
destroyed          false
version            1

====== Data ======
Key         Value
---         -----
password    ...
username    app_admin

3. Update the password to create a second version. Replace NEW_DB_PASSWORD with the rotated password:

docker compose exec openbao bao kv put kv/app/database \
    username=app_admin \
    password=NEW_DB_PASSWORD

The output reports version 2, and clients that read the secret without a version parameter now receive the updated value.

4. Retrieve the earlier version to verify that the history is intact:

docker compose exec openbao bao kv get -version=1 kv/app/database

The output displays the original password along with version 1 in the metadata.

Retrieve the Secret via API

The HTTP API exposes the same operations through Traefik over HTTPS. A client exchanges its credentials for a short-lived client token, then sends that token in the X-Vault-Token header, a name OpenBao retains for compatibility with existing Vault client libraries.

1. Authenticate as appuser to request a client token. Replace STRONG_PASSWORD with the account password, and bao.example.com with your domain name:

curl --request POST \
    --data '{"password": "STRONG_PASSWORD"}' \
    https://bao.example.com/v1/auth/userpass/login/appuser

The response contains an auth object with a client_token field, a policies array listing app-policy and default, and a lease_duration of 2764800 seconds.

2. Export the returned token as a shell variable. Replace CLIENT_TOKEN with the client_token value from the previous response:

export BAO_TOKEN=CLIENT_TOKEN

3. Read the database credential through the API. Replace bao.example.com with your domain name:

curl --header "X-Vault-Token: $BAO_TOKEN" \
    https://bao.example.com/v1/kv/data/app/database

The response nests the secret under data.data and the version details under data.metadata, which reflects the two-layer structure of the version 2 engine.

4. Write a new secret through the API. Replace YOUR_APP_API_KEY with the key your application uses, and bao.example.com with your domain name:

curl --request POST \
    --header "X-Vault-Token: $BAO_TOKEN" \
    --data '{"data": {"api_key": "YOUR_APP_API_KEY"}}' \
    https://bao.example.com/v1/kv/data/app/service

The response returns the created version number and its metadata.

5. Verify that a request outside the permitted prefix fails. Replace bao.example.com with your domain name:

curl --header "X-Vault-Token: $BAO_TOKEN" \
    https://bao.example.com/v1/kv/data/internal/root

The response returns an HTTP 403 status with the body {"errors":["1 error occurred:\n\t* permission denied\n\n"]}, confirming that app-policy restricts the token to the app/ prefix.


Next Steps

OpenBao is running behind HTTPS with Raft storage, audit logging, and a least-privilege policy. From here you can:

  • Enable additional secrets engines such as PKI for certificate issuance, Transit for encryption as a service, or the database engine for dynamic, short-lived credentials
  • Configure auto-unseal with a cloud KMS or a Transit-backed second OpenBao instance so restarts no longer need manual unsealing
  • Add more policies and userpass accounts, or other auth methods, for each application and team
  • Review the official OpenBao documentation for clustering and hardening options

For the full guide with additional tips, visit the original article on Vultr Docs.

About the authors

  • A Developer Advocate with a focus on improving the developer experience through clear communication, technical enablement, and community engagement.
  • DevOps Engineer with experience in Kubernetes, automation, cloud infrastructure, and observability. I work in Developer Relations, contribute to technical documentation, and collaborate on engineering-focused projects.

No comments yet. Be the first to comment.

The Self-Hosted Stack

Part 1 of 50

The Self-Hosted Stack is a developer-focused series exploring open-source tools you can deploy, run, and manage on your own infrastructure. From AI platforms and databases to developer tools, observability stacks, and authentication systems, each guide walks through deploying production-ready open-source software on Vultr cloud infrastructure.

Up nextDeploying Netdata Open-Source Infrastructure Monitoring PlatformDeploy Netdata on a Linux server with Docker Compose, Traefik HTTPS, and basic auth, then tune its cache size, update frequency, and plugins.