Hermes - Part 03: Vault and NGINX, hardened version

In short
  • Certificates issued by the internal PKI (AD CS) with SAN for prdlinage501.coolcorp.priv (Vault) and the alias roger.coolcorp.priv (dashboard), root CA added to the trust store.
  • Single-node Vault 2.2.1 (Raft, TLS, swap disabled), port 8200 filtered by firewalld, 5 unsealing keys (threshold 3) and audit logging enabled.
  • Personal administrator account with userpass, root token revoked, hermes-roger-read policy and AppRole with TTLs and bound_cidrs limited to the VM.
  • NGINX as a TLS frontend for the Hermes dashboard (127.0.0.1:9119), without auth_basic, WebSockets, SELinux, and HTTP redirection to HTTPS.

Introduction

In the previous part, we prepared the VM under Rocky Linux 10 prdlinage501: packages, hermes service account, directory structure, SELinux, rootless Podman with keep-id mapping. We also performed initial tests with the Hermes container image. At the suggestion of the AI, we initiated a Git repository to version configurations and secure elements as we progress.

Now it's time for the two components that run directly on the host: Vault, the vault that will store all of Roger's secrets, and NGINX, the HTTPS frontend for the Hermes dashboard.

For Vault, I am following the logic of part 03 of the OpenClaw series, but correcting the weaknesses that I myself identified: an AppRole access limited to the VM's address, a lifespan for credentials, audit logging, a real administrative account instead of the root token, and port 8200 that is no longer open to the entire LAN. Feel free to take a look at the old article on OpenClaw to learn more about Vault.

On the NGINX side, the change is more radical: it no longer handles authentication; Hermes takes care of that.

Before all this, we need certificates, and that's where we start.

Certificates

Why not just use self-signed certificates? Because a self-signed certificate requires each client to either disable verification or trust each certificate individually. In the first case, we lose all protection against interception. In the second, we multiply the exceptions. With an internal PKI, it is only necessary to trust the root authority once on each machine and in each image, and all certificates it issues are recognized. Since I already have a Windows PKI (AD CS) in my lab, I might as well use it, as I always have.

DNS entries

Two names will point to the VM: its hostname, prdlinage501.coolcorp.priv, which already exists in my DNS from the OpenClaw series, and the name of Roger's dashboard, roger.coolcorp.priv. For the latter, I create an alias (CNAME record) on my Active Directory DNS server, which points to prdlinage501.coolcorp.priv. The advantage is: if the VM's address changes one day, there will only be one record to modify… a classic.

Windows DNS console, coolcorp.priv zone, creation of the CNAME alias roger to prdlinage501.coolcorp.priv

Click the image to enlarge.

We check from the VM:

dig +short prdlinage501.coolcorp.priv
dig +short roger.coolcorp.priv

The first command returns the VM's address. The second displays the target of the alias first, then the same address.

Resolution of prdlinage501.coolcorp.priv and the alias roger.coolcorp.priv using dig

Click the image to enlarge.

The root CA in the trust store

All certificates in the series are issued by my internal PKI (AD CS). To make the VM trust them, we start by installing the root authority certificate on it.

No need to go and retrieve it from the certification server: I retrieved it directly from one of my sites that already uses a certificate issued by my PKI. The file is named CA-COOLCORP.crt and is in text format (PEM, encoded in Base64), so no conversion is necessary. I place it in a folder ~/pki of my administrator account (bvivi57) using a simple drag-and-drop in the MobaXterm file browser (scp or WinSCP also work well).

mkdir -p ~/pki && cd ~/pki
ls
cat CA-COOLCORP.crt

The content must start with -----BEGIN CERTIFICATE-----. If you get unreadable characters, your file is in binary format (DER): convert it with openssl x509 -inform der -in <fichier_in> -out <fichier_out>.crt.

Beginning of the PEM content of the CA-COOLCORP.crt certificate

Click the image to enlarge.

We check that it is indeed the root authority (the subject and issuer must be identical), then we add it to the trusted store of Rocky Linux:

openssl x509 -in CA-COOLCORP.crt -noout -subject -issuer -enddate
sudo cp CA-COOLCORP.crt /etc/pki/ca-trust/source/anchors/CA-COOLCORP.crt
sudo update-ca-trust
trust list | grep -i -A2 coolcorp
Verification of the subject and issuer of the root CA, then adding it to the trusted store

Click the image to enlarge.

We also place a copy for the containers in the hermes account. It will be used by the Vault Agent sidecar, for testing, and for building Roger's image:

sudo install -o hermes -g hermes -m 644 ~/pki/CA-COOLCORP.crt /var/lib/hermes/vault/tls/ca.crt
sudo restorecon -v /var/lib/hermes/vault/tls/ca.crt
Copying the CA to /var/lib/hermes/vault/tls/ca.crt for containers

Click the image to enlarge.

If your PKI includes an intermediate authority (which is usually the case in enterprises), you will need to do the same with its certificate, and later, concatenate the server certificate and the intermediate certificate in the .crt file used by Vault and NGINX.

Certificate requests

We need two server certificates: one for Vault (prdlinage501.coolcorp.priv) and one for NGINX (roger.coolcorp.priv). Modern browsers and tools no longer look at the CN, only the "Subject Alternative Name" (SAN) extension. We are therefore preparing the request with a small OpenSSL configuration file that includes the SANs.

For Vault:

cd ~/pki
cat > prdlinage501.cnf <<'EOF'
[req]
default_bits       = 4096
prompt             = no
distinguished_name = dn
req_extensions     = ext

[dn]
CN = prdlinage501.coolcorp.priv
O  = COOLCORP
C  = FR

[ext]
subjectAltName = DNS:prdlinage501.coolcorp.priv, DNS:prdlinage501, IP:192.168.10.41
keyUsage = critical, digitalSignature, keyEncipherment
extendedKeyUsage = serverAuth
EOF

openssl req -new -newkey rsa:4096 -nodes -config prdlinage501.cnf \
  -keyout prdlinage501.key -out prdlinage501.csr
openssl req -in prdlinage501.csr -noout -text | grep -A1 "Subject Alternative Name"
OpenSSL configuration file prdlinage501.cnf with SANs Generating the key and certificate request prdlinage501.csr, and checking the SAN (Subject Alternative Name) settings

Click the image to enlarge.

And for Roger's dashboard, we keep the same configuration but simply replace the name associated with the certificate (the AI provides the small sed command that will do the trick):

sed -e 's/prdlinage501.coolcorp.priv/roger.coolcorp.priv/' \
    -e 's/^subjectAltName = .*/subjectAltName = DNS:roger.coolcorp.priv/' \
    prdlinage501.cnf > roger.cnf
openssl req -new -newkey rsa:4096 -nodes -config roger.cnf \
  -keyout roger.key -out roger.csr
openssl req -in roger.csr -noout -text | grep -A1 "Subject Alternative Name"
chmod 600 ~/pki/*.key
Generating the certificate request roger.csr and checking the SAN roger.coolcorp.priv Restricting the permissions of the private keys to 600

Click the image to enlarge.

Issuance from AD CS

We copy the two .csr files to a Windows machine that has access to the authority (personally, I use the CA server itself, but in real life, we avoid this), and we submit them with certreq, specifying the certificate template. I use my usual web server template, TPL-SRV-WEB-DEFAULT, configured to accept the name provided in the request.

This is essential: if the template constructs the subject from Active Directory, the SANs in the request are ignored.

Copying the CSR files to the Certificate Authority server

Click the image to enlarge.

certreq -submit -attrib "CertificateTemplate:TPL-SRV-WEB-DEFAULT" prdlinage501.csr prdlinage501.cer
certreq -submit -attrib "CertificateTemplate:TPL-SRV-WEB-DEFAULT" roger.csr roger.cer

certreq prompts you to choose the authority, and then saves the issued certificates. Note that the attribute expects the name of the template, not its full name displayed in the console.

Submitting the requests using certreq and selecting the CA-COOLCORP certificate authority

Click the image to enlarge.

I will not go into further detail about how certificates work with a Microsoft AD CS ecosystem; that is not the purpose of this article. If you have other PKI mechanisms, you can use them just as well; the important thing is to have certificates recognized on your architecture.

Back on the VM, we check the two certificates. certreq generally produces Base64 (PEM):

cd ~/pki
for c in prdlinage501 roger; do
  openssl x509 -in $c.cer -out $c.crt
  openssl x509 -in $c.crt -noout -subject -issuer -enddate -ext subjectAltName
  openssl verify -CAfile CA-COOLCORP.crt $c.crt
done
The issued certificates prdlinage501.cer and roger.cer are returned to the VM Converting and verifying both certificates using openssl verify

Click the image to enlarge.

We expect two OK for openssl verify.

Vault

Reminder: What is Vault used for?

For those who are new to this series, a quick reminder. Vault, published by HashiCorp, is a secrets vault. Instead of leaving passwords, tokens, and API keys in configuration files, we store them in Vault, which encrypts them and only releases them to those authorized to read them.

I like the analogy of a bank vault. The vault room is closed (Vault is "sealed") until multiple key holders have come together to open it. Each client has their own locker (a path in the KV Key/Value engine) and an access card that only grants access to that locker (a policy). And the register at the entrance records each entry (the audit log).

For Roger, we will use three mechanisms:

  • The KV engine version 2, which stores key/value pairs and keeps a history of each secret's versions: any typos can be corrected.
  • A policy, which precisely describes the paths that an identity is allowed to read.
  • AppRole is an authentication method designed for machines. The role_id acts as an identifier, the secret_id as a password, and together they allow you to obtain a temporary token.

It is the Vault Agent sidecar, which we will start in part 06, that will use this AppRole. Roger itself will never talk to Vault directly.

Integration schema with Vault: the vault-agent-roger sidecar presents the role_id and secret_id, Vault verifies the secret_id and source IP address, then returns a one-hour token. The sidecar requests the secrets using this token, Vault verifies the token and the hermes-roger-read policy, logs the request, and returns the value, which is written to the .env file read by Roger

Click the image to enlarge.

Once again, feel free to read my part 03 of my articles on OpenClaw, where I explain the principles behind Vault in more detail.

Installation

Vault is installed from the official HashiCorp repository. I am using version 2.2.1, which was the latest version at the time of writing (the OpenClaw series used 2.0.1):

sudo dnf install -y dnf-plugins-core
sudo dnf config-manager --add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo
sudo dnf install -y vault-2.2.1
vault version
Adding the HashiCorp repository and installing Vault 2.2.1 Completion of the Vault installation and generation of the self-signed certificate in /opt/vault/tls Result of the vault version command: Vault v2.2.1

Click the image to enlarge.

The package creates the user vault, the systemd service, and the directories /etc/vault.d and /opt/vault. It also generates a self-signed certificate (tls.crt and tls.key) in /opt/vault/tls. We won't use it; we just place the certificate issued by our PKI next to it.

We install the TLS files and prepare the audit log directory:

sudo install -o root -g vault -m 644 ~/pki/prdlinage501.crt /opt/vault/tls/vault.crt
sudo install -o root -g vault -m 640 ~/pki/prdlinage501.key /opt/vault/tls/vault.key
sudo mkdir -p /opt/vault/logs && sudo chown vault:vault /opt/vault/logs && sudo chmod 750 /opt/vault/logs
sudo ls -l /opt/vault/ /opt/vault/tls/

You must find vault.crt and vault.key within /opt/vault/tls, as well as the folder logs. If you fail this check, Vault will refuse to start with the error error loading TLS cert: open /opt/vault/tls/vault.crt: no such file or directory.

Error error loading TLS cert in the Vault log when vault.crt is missing from /opt/vault/tls Contents of /opt/vault and /opt/vault/tls, including vault.crt, vault.key, and the logs directory

Click the image to enlarge.

Configuration

We replace the default configuration file. We switch to a single-node configuration. Since Vault is designed to run in a cluster using resilience mechanisms (the Raft protocol), in our case, we need to use a single server, listening on TLS port 8200, with the web interface enabled:

sudo tee /etc/vault.d/vault.hcl >/dev/null <<'EOF'
# /etc/vault.d/vault.hcl - Vault 2.2.1 mono-nœud (prdlinage501)
ui            = true
cluster_name  = "coolcorp-vault"
# Recommandé avec le stockage intégré ; la swap est désactivée sur la VM
disable_mlock = true

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

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

api_addr     = "https://prdlinage501.coolcorp.priv:8200"
cluster_addr = "https://prdlinage501.coolcorp.priv:8201"
EOF
sudo chown root:vault /etc/vault.d/vault.hcl && sudo chmod 640 /etc/vault.d/vault.hcl
Writing the /etc/vault.d/vault.hcl file for single-node operation with Raft storage and a TLS listener Setting permissions to root:vault and 640 on vault.hcl

Click the image to enlarge.

As in the OpenClaw series, we disable the swap: with disable_mlock, Vault can no longer prevent the system from writing its memory, and therefore secrets, to the disk.

sudo swapoff -a
sudo sed -i '/\sswap\s/ s/^/#/' /etc/fstab
free -h | grep -i swap
Disabling swap and checking with free -h

Click the image to enlarge.

Coming back to the single-node configuration: in companies, it is generally recommended to have several Vault instances that can take over from one another in case of an incident. Be aware, though, that this means more operational maintenance, and certain conditions must be met for resilience to work properly, starting with a minimum of three installations. That's why, in my case, I am sticking with a single instance.

A less open port 8200

In the previous series with OpenClaw, port 8200 was open to the entire LAN. Yet its only clients are the Vault Agent sidecar, which runs on the VM itself, and my administration workstation for the web interface. So we restrict access with two firewalld rules, replacing <IP_POSTE_ADMIN> with the address of the workstation that needs access to the GUI:

sudo firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="192.168.10.41/32" port port="8200" protocol="tcp" accept'
sudo firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="<IP_POSTE_ADMIN>/32" port port="8200" protocol="tcp" accept'
sudo firewall-cmd --reload
sudo firewall-cmd --list-rich-rules
Adding firewalld rules that limit port 8200 to the VM and the administration workstation List of rich firewalld rules on port 8200

Click the image to enlarge.

A small uncertainty to note: the source address from which Vault will see requests from rootless containers depends on Podman's network mode. I expect it to be the VM's address, but we will verify this formally in part 06 using the audit log. If that is not the case, we will expand the rule.

Startup, initialization and unsealing

sudo systemctl enable --now vault
echo 'export VAULT_ADDR=https://prdlinage501.coolcorp.priv:8200' >> ~/.bashrc
source ~/.bashrc
vault status
Vault service is active and running, as confirmed by systemctl status vault status: Vault not initialized and sealed

Click the image to enlarge.

We initialize Vault with five unsealing keys, three of which are required to open it:

vault operator init -key-shares=5 -key-threshold=3
Warning: This output is extremely critical; it contains the five unsealing keys and the initial root token. Store them in your password manager, ideally in different locations, and never on the VM. Without three of these keys, your secrets are lost. End of story.
Running vault operator init with the unsealing keys and root token masked

Click the image to enlarge.

Why five keys, with three required? Vault encrypts all its data with a master key, which is never stored in plain text. This key is divided into five parts using Shamir's algorithm, and three parts are sufficient to reconstruct it. In an enterprise environment, each part is entrusted to a different person: no single person can open the vault, and the loss of one or two keys is not fatal. In a home lab, I am the only holder.

We then unseal Vault by entering three of the five keys, one per command:

vault operator unseal
vault operator unseal
vault operator unseal
vault status | grep -E 'Sealed|Storage Type|HA Enabled'

We expect Sealed false and Storage Type raft.

Unsealing Vault in three steps using vault operator unseal

Click the image to enlarge.

Vault does not unseal itself. After each VM restart, this operation will have to be done again, otherwise Roger will no longer have access to its secrets. Auto-unseal mechanisms exist, but they rely on an external service: a cloud KMS, an HSM or a second Vault instance. For a home lab, I am sticking with manual unsealing, and in part 07 we will set up a Telegram alert if Vault is sealed.

Enabling features

We temporarily connect using the root token and enable the KV version 2 secret engine, as well as the AppRole authentication methods (for agents) and userpass (for me), and the audit log:

vault login            # saisir le token root
vault secrets enable -path=secret -version=2 kv
vault auth enable approle
vault auth enable userpass
vault audit enable file file_path=/opt/vault/logs/audit.log
vault secrets list && vault auth list && vault audit list
Temporary connection using the root token (masked). Enabling the KV v2 engine, approle and userpass methods, and the audit log

Click the image to enlarge.

The audit log is new compared to the OpenClaw series. Every request made to Vault is recorded here, along with the identity and source address; sensitive values are hashed. This will tell us who accessed what, and when.

Each line in the file is a JSON document. It includes the event type (request or response), the requested path, the authenticated identity (e.g., approle for Roger's sidecar), and the original IP address. The values of the secrets never appear in plain text; Vault replaces them with a hash. We will use this in Part 06 to verify the address at which Vault sees the containers, and in Part 07 for auditing.

A precaution: this log grows over time. In a home lab, the volume remains modest, but consider implementing rotation using logrotate if you run the platform for several months. Be aware that if Vault can no longer write to its only audit log (e.g., because the disk is full), it will refuse all requests. This is intentional: no trace, no access.

An administrative account instead of the root token

In the previous series, I worked with the root token from beginning to end. This is convenient, but it's exactly what you shouldn't do. Therefore, we create an administrative policy and a vault user bvivi57. The policies are versioned in the Git repository (cloned in Part 02):

cd ~/roger.coolcorp.priv
cat > vault/policies/admin-coolcorp.hcl <<'EOF'
# Administration complète de Vault (compte humain uniquement)
path "*" {
  capabilities = ["create", "read", "update", "delete", "list", "sudo"]
}
EOF
vault policy write admin-coolcorp vault/policies/admin-coolcorp.hcl
Creating and loading the admin-coolcorp policy

Click the image to enlarge.

set +o history
read -rsp "Mot de passe Vault pour bvivi57 : " VPASS && echo
vault write auth/userpass/users/bvivi57 password="$VPASS" policies="admin-coolcorp" token_ttl=8h token_max_ttl=24h
unset VPASS
set -o history
Entering the masked Vault password for bvivi57 Creating the userpass account bvivi57 with the admin-coolcorp policy Removing the VPASS variable and re-enabling history

Click the image to enlarge.

The command set +o history prevents the password from appearing in the shell history. We will use this practice for every secret manipulation.

We switch to this new account, and then revoke the root token:

read -rsp "Token root : " ROOT_TOKEN && echo
vault login -method=userpass username=bvivi57
vault token revoke "$ROOT_TOKEN"
unset ROOT_TOKEN
vault token lookup | grep -E 'display_name|policies'
Connecting to Vault using the bvivi57 userpass account (token masked). Revoking the root token and checking the current identity

Click the image to enlarge.

Don't worry: if needed, a new root token can be regenerated with the unseal keys (vault operator generate-root).

Roger's policy and AppRole

We now come to the part that directly concerns Roger. All its secrets will live under secret/hermes/roger/. Its policy grants it the right to read them, and nothing else:

cat > vault/policies/hermes-roger-read.hcl <<'EOF'
# Lecture seule sur la branche de Roger (toutes ses futures dépendances y vivent)
path "secret/data/hermes/roger/*" {
  capabilities = ["read"]
}
path "secret/metadata/hermes/roger/*" {
  capabilities = ["list", "read"]
}
# Renouvellement et consultation de son propre token par Vault Agent
path "auth/token/renew-self" {
  capabilities = ["update"]
}
path "auth/token/lookup-self" {
  capabilities = ["read"]
}
EOF
vault policy write hermes-roger-read vault/policies/hermes-roger-read.hcl
Creating the hermes-roger-read policy for read-only access Loading the hermes-roger-read policy into Vault

Click the image to enlarge.

Then there's the AppRole, used by the Vault Agent sidecar for authentication. This is where most of the hardening compared to OpenClaw comes into play:

vault write auth/approle/role/hermes-roger \
  token_policies="hermes-roger-read" \
  token_ttl=1h \
  token_max_ttl=24h \
  secret_id_ttl=8760h \
  secret_id_num_uses=0 \
  secret_id_bound_cidrs="192.168.10.41/32,127.0.0.1/32" \
  token_bound_cidrs="192.168.10.41/32,127.0.0.1/32"
vault read auth/approle/role/hermes-roger

Some explanations:

  • token_ttl and token_max_ttl: The token obtained by the agent is valid for one hour and cannot be extended beyond 24 hours; the Vault Agent automatically reauthenticates itself.
  • secret_id_ttl=8760h: The secret identifier expires after one year, whereas it was permanent in the OpenClaw series; we will see its renewal in Part 07.
  • secret_id_bound_cidrs and token_bound_cidrs: The secret_id and the tokens can only be used from within the virtual machine. If stolen, the role_id/secret_id pair would be useless from another machine.
vault read auth/approle/role/hermes-roger, showing the TTL and bound_cidrs

Click the image to enlarge.

To go further, Vault allows a higher level of protection: a single-use secret_id (secret_id_num_uses=1), delivered "wrapped" (response wrapping) and unwrapped by the agent at startup. The secret then never exists in clear text on disk, or only for a few seconds. I did not choose this here: every restart of the sidecar would require generating a new secret, which calls for extra automation that I find disproportionate for a home lab. But in a company, it is a serious option.

One last point about these durations: they have a direct impact on operations. A one-hour token is worthless if it is stolen and not used quickly. A one-year secret_id is an annual appointment not to be missed, otherwise the sidecar will no longer be able to authenticate and Roger will lose its secrets. We will set up a reminder in part 07.

The role_id is not a secret in itself: it is the equivalent of a username. We drop it into the hermes directory tree right away, in 600, since thanks to keep-id the container will read it with the identity of the hermes account:

vault read -field=role_id auth/approle/role/hermes-roger/role-id | \
  sudo install -o hermes -g hermes -m 600 /dev/stdin /var/lib/hermes/vault/roger-role-id
sudo restorecon -v /var/lib/hermes/vault/roger-role-id
sudo ls -lZ /var/lib/hermes/vault/
Storing the role_id in /var/lib/hermes/vault/roger-role-id with permissions 600 and the context container_file_t

Click the image to enlarge.

The secret_id will be generated in Part 05, once all of Roger's secrets have been registered. This will allow us to test the entire chain at once.

The web interface

The Vault interface is accessible from the administration workstation at https://prdlinage501.coolcorp.priv:8200/ui. You can connect to it using the "Userpass" method with the account bvivi57. Currently, the secret/ engine is empty, which is normal.

Connecting to the Vault web interface using the Userpass method The secret/KV version 2 engine is still empty in the Vault web interface

Click the image to enlarge.

NGINX

Installation and certificate

Now we move on to the frontend. The principle is the same as in the OpenClaw series: NGINX terminates TLS on roger.coolcorp.priv and forwards requests to the Hermes dashboard, which will only listen on 127.0.0.1:9119. The difference is the absence of auth_basic: the Hermes dashboard enforces its own authentication as soon as it's exposed. A double authentication would only result in a double login prompt.

sudo dnf install -y nginx
sudo install -m 644 ~/pki/roger.crt /etc/pki/tls/certs/roger.coolcorp.priv.crt
sudo install -m 600 ~/pki/roger.key /etc/pki/tls/private/roger.coolcorp.priv.key
sudo restorecon -v /etc/pki/tls/certs/roger.coolcorp.priv.crt /etc/pki/tls/private/roger.coolcorp.priv.key
Installing NGINX 1.26 from the Rocky Linux repositories Installing the certificate and key for roger.coolcorp.priv

Click the image to enlarge.

Configuration

sudo tee /etc/nginx/conf.d/roger.conf >/dev/null <<'EOF'
# /etc/nginx/conf.d/roger.conf - TLS + FQDN devant le dashboard Hermes de Roger.
# L'authentification est celle du dashboard (pas d'auth_basic : éviter la double invite).
server {
    listen 443 ssl;
    http2 on;
    server_name roger.coolcorp.priv;

    ssl_certificate     /etc/pki/tls/certs/roger.coolcorp.priv.crt;
    ssl_certificate_key /etc/pki/tls/private/roger.coolcorp.priv.key;
    ssl_protocols TLSv1.2 TLSv1.3;

    # Restreindre au LAN d'administration
    allow 192.168.10.0/24;
    deny all;

    location / {
        proxy_pass http://127.0.0.1:9119;
        proxy_http_version 1.1;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-Proto https;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header X-Real-IP $remote_addr;
        # Le chat intégré au dashboard utilise des WebSockets
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_read_timeout 3600;
        proxy_buffering off;
    }
}

server {
    listen 80;
    server_name roger.coolcorp.priv;
    return 301 https://$host$request_uri;
}
EOF
File /etc/nginx/conf.d/roger.conf: TLS, LAN restriction, proxy to 127.0.0.1:9119, and WebSockets

Click the image to enlarge.

Here are some explanations about this configuration:

  • the allow 192.168.10.0/24 directive limits access to the dashboard to my local network; everything else gets a 403 error before even reaching Hermes.
  • the X-Forwarded-* and X-Real-IP headers pass on to Hermes the browser's real address and the fact that the original connection was encrypted. The dashboard needs them to build its links and secure its cookies.
  • the Upgrade and Connection headers allow WebSockets through, used by the chat built into the dashboard.
  • The long read timeout (proxy_read_timeout) prevents NGINX from cutting off a conversation while the model is processing.
  • The second block simply redirects HTTP to HTTPS.

SELinux and firewall

By default, SELinux prevents NGINX from opening network connections to an arbitrary port. We declare port 9119 as an HTTP port and enable the corresponding boolean:

sudo semanage port -a -t http_port_t -p tcp 9119
sudo setsebool -P httpd_can_network_connect 1
sudo semanage port -l | grep -w 9119
Declaring port 9119 as http_port_t and enabling the httpd_can_network_connect boolean

Click the image to enlarge.

If semanage port -a reports that the port is already defined, replace -a with -m.

We open HTTP (for redirection) and HTTPS, validate the configuration, and start:

sudo firewall-cmd --permanent --add-service=http --add-service=https
sudo firewall-cmd --reload
sudo nginx -t
sudo systemctl enable --now nginx
Opening HTTP/HTTPS in firewalld, testing the NGINX configuration, and starting the service

Click the image to enlarge.

Verification

Hermes is not running yet, so we expect a 502 error. But this is a good error: it proves that TLS, the hostname, and the proxy are working.

curl -sI https://roger.coolcorp.priv | head -1
curl -sI http://roger.coolcorp.priv | grep -i -E '^HTTP|^location'
Curl test: 502 error on HTTPS and a 301 redirect from HTTP

Click the image to enlarge.

From the browser on the administration machine, the page https://roger.coolcorp.priv should display the padlock without any warnings (if the root CA is properly deployed on your machine), along with a "502 Bad Gateway" page.

Details of the roger.coolcorp.priv certificate issued by CA-COOLCORP in the browser NGINX 502 Bad Gateway page on https://roger.coolcorp.priv

Click the image to enlarge.

What has changed compared to OpenClaw

For those who followed the previous series, here's a summary of the differences in this article:

  • Version: Vault 2.2.1 instead of 2.0.1, with no change in principle.
  • Network Access: Port 8200 is no longer open to the entire LAN; it's only accessible from the VM and the administration machine.
  • Administration: A dedicated account 'bvivi57' with its own policy, and a root token that is revoked after use.
  • Auditing: An audit log is enabled from the installation.
  • AppRole: Credentials with a limited lifespan that can only be used from the VM, with files set to 600 instead of 644.
  • NGINX: No more basic authentication or trusted-proxy mode; authentication is delegated to the Hermes dashboard.
  • Versioning: Policies and configuration files are added to the Git repository.

None of these improvements are revolutionary on their own. However, when combined, they significantly reduce the attack surface. This is often how security works: no magic bullet, but an accumulation of small precautions.

A recap before continuing

  • vault status shows Initialized true and Sealed false, and the unseal keys are stored outside the VM.
  • The secret/ (KV v2) engine, AppRole and userpass methods, and the audit log are enabled.
  • Connection with the bvivi57 account works, and the root token is revoked.
  • The policy hermes-roger-read and the role hermes-roger exist, along with the bound_cidrs.
  • The file /var/lib/hermes/vault/roger-role-id has permissions 600, owner hermes, and SELinux type container_file_t.
  • The CA is in the VM's trusted store and in /var/lib/hermes/vault/tls/ca.crt.
  • https://roger.coolcorp.priv returns a 502 error with a valid certificate.

Archiving

We finish by moving the configurations to the Git repository. The policies are already in the repository; the script retrieves vault.hcl and roger.conf:

cd ~/roger.coolcorp.priv
sudo ./scripts/collect.sh
git status
git add -A && git commit -m "Partie 03 : Vault 2.2.1, policies et NGINX" && git push
Collecting configurations, committing, and pushing part 03 (URL masked).

Click the image to enlarge.

The files in the folder ~/pki (including private keys) remain on the VM, outside the repository. Once the certificates are installed, you can delete the private keys from this folder (shred -u ~/pki/*.key), since they have been copied to their final location.

Conclusion

Vault is set up and hardened compared to the version in the OpenClaw series: AppRole linked to the VM's address, short-lived credentials, audit log, dedicated administrator account, and port 8200 filtered. NGINX awaits Roger's dashboard behind a certificate from the internal PKI.

One accepted limitation remains: manual unsealing after each restart. It is the price of a standalone Vault without an external service, and we will take it into account in operations.

In the next article, we'll deal with Roger's brains: LM Studio on the Mac, properly exposed to the VM, and the GLM key from Z.ai. Their first secrets will fill our brand new vault. See you in part 04: Roger's brains, LM Studio on Mac, and GLM (Z.ai).