A Traefik middleware that enables seamless login to Nomad when operated behind Cloudflare Zero Trust.
The middleware utilizes Nomad's JWT authentication and Cloudflare's application tokens to exchange a JWT token from Cloudflare into Nomad's ACL token. After that, the token injected as header into every request.
This results with a seamless login into Nomad UI (and API).
The setup instructions covers basic setup scenario. It assumes that:
In Nomad, add a new JWT auth method:
echo '{"JWKSURL": "https://<your team>.cloudflareaccess.com/cdn-cgi/access/certs","BoundIssuer": ["https://<your team>.cloudflareaccess.com"],"BoundAudiences": ["<application audiance tag>"],"SigningAlgs": ["RS256"]}' | nomad acl auth-method create -name Cloudflare -token-locality global -type JWT -max-token-ttl 8h -config -
Make sure to config the above to fit your setup.
First, add plugin configuration in the static config:
experimental:plugins:cfauth:moduleName: github.com/strigo/traefik-auth-middlewareversion: v0.1.0
Now add the middleware into your routing config. Here's one example:
http:middlewares:auth:plugin:cfauth:authMethodName: CloudflarenomadEndpoint: http://localhost:4646services:nomad:loadBalancer:servers:- url: "http://localhost:4646/"routers:nomad:entrypoints:- webservice: nomadrule: "Host(`example.com`)"middlewares:- auth
Feel free to open an issue request.
ʕ•ᴥ•ʔ