This guide covers setting up a HashiCorp Nomad cluster secured with mutual TLS where certificates are manually managed (use Hashicorp Vault to easily automate the process)
- Allow RPC port (default 4647) in the VPS/firewall that will run the Nomad server agent.
### if using ufw
sudo ufw allow 4647- Set up the env variables
export DOMAIN=<demo.com> export REGION=global
- Use certs.sh to generate the CA and server/client certificates for your domain.
-
Copy the server certificates and
${DOMAIN}-agent.ca.pemto the server VPS. -
Update the
server.nomad.hclconfiguration{DOMAIN}placeholders and the correct certificate paths. -
Start the server agent:
nomad agent -config server.nomad.hcl
- Update traefik/nomad.yaml
{DOMAIN}placeholder accordingly and apply it to an existing traefik service running on the server VPS.
- Set up your environment variables to authenticate securely via mTLS:
export NOMAD_ADDR="https://${DOMAIN}"
export NOMAD_CACERT="$(pwd)/certs/${DOMAIN}-agent-ca.pem"
export NOMAD_CLIENT_CERT="$(pwd)/certs/client/${REGION}-client-${DOMAIN}.pem"
export NOMAD_CLIENT_KEY="$(pwd)/certs/client/${REGION}-client-${DOMAIN}-key.pem"- Test the connection
nomad job status - Copy the client certificates and
${DOMAIN}-agent.ca.pemto your client VPS. - Update your
client.nomad.hclconfiguration and{DOMAIN}placeholders accordingly - Start the client agent:
nomad agent -config client.nomad.hcl
Note: The client can be started with optional introduction token if strict enforcement is required. Generate the token on cli nomad node intro create then provide it nomad agent -config ./client.nomad.hcl -client-intro-token <TOKEN>
-
Generate a client certificate if you haven't already:
nomad tls cert create -client -domain=${DOMAIN} -additional-dnsname=${DOMAIN} -additional-dnsname=client.${REGION}.nomad
-
Convert the certificate files into PKCS#12 format for browser import:
openssl pkcs12 -export -inkey ./${REGION}-client-${DOMAIN}-key.pem -in ./${REGION}-client-${DOMAIN}.pem -out ./${DOMAIN}-browser.pfx
-
Import the
.pfxfile into your browser's personal certificate store:- Chrome / Brave / Edge: Settings -> Privacy and security -> Security -> Manage certificates.
- Firefox: Settings -> Privacy & Security -> Certificates -> View Certificates.
-
Import the CA certificate (
nomad.${DOMAIN}-agent.ca.pem) into your browser or OS trust store as a Trusted Root Certification Authority. -
Navigate to
https://${DOMAIN}in your browser. A prompt to select the imported certificate will appear if the certificates from step 2 were installed in the OS trust store.