Load balancer doesn't work

I tried setting up my load balancer on a subdomain of my website (lb.lrai.com.au) and it fails to return anything at all. It’s a very simple load balancer with server1.lrai.com.au and server2.lrai.com.au as the origins (both are being served via cloudflared tunnels). So basically my origin works if I visit the websites. So the weird thing is that my origin pools are all working (in terms of health checks, and their subdomains), but my load balancer subdomain returns nothing. I toyed around with Host headers but it basically made things even worse. I am using Nginx to serve my website and the allowed hosts is already very flexible (i included all possible domains including lb.lrai.com.au). I am also serving the website using Cloudflare Origin SSL certificates which should already cover all my bases. Why is this the case and how can I make it work?

it gets even weirder. So I found that if a do a curl command to query lb.lrai.com.au it actually works except that the HTTP Host header is set to lb.lrai.com.au and is thus rejected by the cloudflared tunnel (which requires server1.lrai.com.au as the host header). So i tried 2 ways of going about it - first is setting the cloudflared tunnel settings to force the host header to be overridden to server1.lrai.com.au, second is setting the load balancer origin pool settings to force the host header to be overridden to server1.lrai.com.au. Both doesn’t work - my curl command still shows lb.lrai.com.au as the host header. So this is unsolvable then for people who want to use cloudflared tunnels alongside their load balancers - i can’t set the cloudflared ingress to allow traffic from lb.lrai.com.au without changing the DNS, and multiple tunnels (and thus servers) can’t share the same DNS link (which defeats the whole purpose of the load balancer).

I figured out how to solve it. I will share what I did. So basically you can’t use the actual subdomain as your origin source (for e.g. server1.lrai.com.au), you have to use the actual tunnel which is sometunnelid.cfargotunnel.com (you can check that in the DNS). Then, you have to use the tunnel subdomain (for e.g. server1.lrai.com.au) as the Host header (otherwise nothing will work). Similar to what I did before, you need to tunnel to some subdomain so that you can use it as the host header.

So basically:

  1. create separate cloudflared tunnels for each server which points to separate subdomains.
  2. look up the tunnel id by checking the DNS record for the tunnel subdomain.
  3. for the origin pool settings, set the source to sometunnelid.cfargotunnel.com and host header to your tunnel subdomain (for e.g. server1.lrai.com.au)

and then it should work!

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.