Skip to content
Tutorials Center
My learning

Topics

Lesson 27 of 36 ยท Deployment and HA

Vault Production Server Configuration: HCL, Listener and TLS

Write a production Vault server config file: listener with TLS, storage, api_addr and cluster_addr, UI, telemetry, mlock, hardening checklist and a config checker stand-in.

Dev mode (vault server -dev) keeps everything in memory, uses plain HTTP and prints a root token. It is wonderful for learning and unacceptable for real secrets. A production server reads an HCL configuration file, stores data durably, serves only TLS and starts sealed. This lesson walks through each block and highlights the settings people most often get wrong.

The Vault server does not run on this site. The configuration below is what you would put on a real host. The checker is a JavaScript stand-in with a few illustrative rules, not an official validator; always read the real docs for your version.

A minimal production file

HCL
ui            = true
disable_mlock = true          # required with Integrated Storage in most setups
cluster_name  = "prod-eu"

storage "raft" {
  path    = "/opt/vault/data"
  node_id = "vault-1"
}

listener "tcp" {
  address         = "0.0.0.0:8200"
  cluster_address = "0.0.0.0:8201"
  tls_cert_file   = "/etc/vault/tls/vault.crt"
  tls_key_file    = "/etc/vault/tls/vault.key"
  tls_min_version = "tls12"
}

api_addr     = "https://vault-1.example.internal:8200"
cluster_addr = "https://vault-1.example.internal:8201"

telemetry {
  prometheus_retention_time = "30s"
  disable_hostname          = true
}

Start it with vault server -config=/etc/vault/vault.hcl, usually under systemd as an unprivileged vault user.

Block by block

  • storage chooses where encrypted data lives. Integrated Storage (raft) is the recommended default; Consul and others exist. See Integrated Storage.
  • listener "tcp" defines the API endpoint. Set tls_cert_file and tls_key_file; never use tls_disable = 1 outside a local test. Port 8200 is the API, 8201 is cluster traffic between nodes.
  • api_addr is the address clients (and redirecting standbys) should use. cluster_addr is for server-to-server traffic. Wrong values are the most common cause of HA redirects that fail.
  • seal (optional) configures auto-unseal, see HA and auto-unseal.
  • telemetry exposes metrics for Prometheus, StatsD or Datadog.
  • disable_mlock stops Vault from locking memory. Vault normally uses mlock so secrets are not swapped to disk; with Integrated Storage the docs recommend disabling it and turning swap off on the host instead.
  • default_lease_ttl and max_lease_ttl set system defaults (768h default max).

Environment variables and secrets in the config

Do not put secret values such as KMS credentials in the file when you can use instance roles. Some values can come from the environment (VAULT_ADDR, AWS_REGION). Files should be readable only by the vault user (mode 0640).

Hardening checklist

  1. TLS everywhere, certificates from your internal CA, minimum TLS 1.2.
  2. Run as a dedicated non-root user; use systemd sandbox options.
  3. Turn off swap, disable core dumps (ulimit -c 0).
  4. Restrict network access to 8200/8201 with a firewall or security group.
  5. Enable at least one audit device before serving traffic (audit devices).
  6. Revoke the root token after bootstrapping.
  7. Keep Vault single-purpose on its host; avoid co-hosting other services.
  8. Auto-unseal with a cloud KMS or HSM.
JS Stand-in: a tiny config checker

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Running as a service and first start

Terminal
sudo systemctl enable --now vault
export VAULT_ADDR=https://vault-1.example.internal:8200
vault status          # Initialized false, Sealed true
vault operator init   # prints unseal keys and the initial root token

Store unseal key shares (or recovery keys with auto-unseal) with different people, and log in with the root token only to set up real authentication.

JS Stand-in: which port is for what?

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which listener setting must never be used for real secrets outside a local test?

    Disabling TLS sends tokens and secrets in clear text.
  2. 2. What is api_addr used for?

    Redirects and client-facing URLs use api_addr; a wrong value breaks HA forwarding.
  3. 3. What is the state of a freshly started, newly initialized server?

    Vault starts sealed and must be unsealed manually or with auto-unseal.
  4. 4. Port 8201 carries:

    Server-to-server communication uses the cluster address.

Summary

  • Production means a config file, durable storage, TLS and a sealed start.
  • api_addr and cluster_addr must be correct for HA.
  • Harden the host, restrict ports, enable audit and revoke the root token.

Next: Integrated Storage (Raft)