Cloudflared tunnel error

My Java application deployed in 4 active servers(app1/app2/app3/app4). I use NGINX as load balancer to route traffic to my java application. NGINX is installed on 2 servers (lb1/lb2). Both nginx are active and serve requests at 50-50 ration

i want to secure my traffic to load balancers using Cloudflare tunnel.
so i created/configured Cloudflare tunnel locally on lb1
CNAME(cfargotunnel)record created automatically in Cloudflare UI and working perfect.

when i execute the same in lb2 its failing at below command
“cloudflared tunnel route dns prodshoptunnel2 shop.techxenon”
getting error “Failed to add route: code: 1003, reason: An A, AAAA, or CNAME record with that host already exists”

i understood that CNAME is already created by tunnel on lb1(prodshoptunnel1).

How to resolve this?
The point is i need to bring two NGINX load balancers into Cloudflare tunnel scope to serve traffic.

flow is Browser–>Cloudflare–Nginx(loadbalancer1/2)–java server

Just run cloudflared tunnel run on lb2 with the same config.yml and uuid.json.

1 Like

Hi @pieak

lb1—>tunnel id is abc-def.json(tunnel name is ‘prodshoptunnel1’)
lb2—>tunnel id is uvw-xyz.json(tunnel name is ‘prodshoptunnel2’).

as suggested, lb1 and lb2 have same config.yml and uuid.json(abc-def.json). it did not work.
i guess becasue as the tunnel id is maintained by Cloudflare which is not recognising this tunnel on lb2.

just to mention, i skipped “cloudflared tunnel route dns prodshoptunnel2 shop.techxenon” on lb2.

please correct me if i am wrong

I am not quite sure what’s wrong with your configuration.
But the correct configuration for development should be like this:

Local PC:

  1. cloudflared tunnel login
  2. cloudflared tunnel create prodshoptunnel
  3. cloudflared tunnel route dns prodshoptunnel shop.techxenon

NEVER upload cert.pem.

LB1:

  1. Create a configuration file.
  2. Upload UUID.json.
  3. cloudflared tunnel run prodshoptunnel

LB2:

  1. configuration file copied from LB1.
  2. UUID.json copied from LB2.
  3. cloudflared tunnel run prodshoptunnel

Now everything should work.

For production, https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/run-tunnel/as-a-service/ and https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/configuration/arguments/ might be helpful.

Hi @pieak , Thanks for the info.

Its working perfect on lb1 and lb2 but with a problem.
The connectors on lb1 and lb2 are shutting down(not persistent) or deleted when i logged out of machines.

These are what you need. :grinning: