TrueNas Cloudflared Tunnel Returning Error 502 Bad Gateway

Hello, I recently made a computer to use as a server, and I want some services such as nextcloud and jellyfin to be accessible over the internet. I decided the best way to do this would be by using Cloudflare tunnels so I wouldn’t have to port forward.

To do this, I purchased a domain using GoDaddy, set up a Cloudflare account, and connected the Cloudflare nameservers to my domain. After this, I went into Tunnel settings and created a tunnel to two of my services: pihole and nextcloud. These are both set up the same way with HTTPS and noTLSVerify set to true. The tunnels are listed as healthy. The only problem is, when I put in the URL for pihole into my browser, I get a 502 error and when I go to the nextcloud URL it routes me directly to the IP address. When I try to access the URL for nextcloud over data on my phone it is unable to connect. I also set up the root of my domain to point to the TrueNAS homepage using straight DNS, which works.

My server is running TrueNAS Scale as well as the TrueCharts Cloudflared Docker container.

If anyone knows why this is happening, please let me know. Any tips or recommendations are appreciated!

Here is the log error message I get when trying to access pihole:

2022-12-26 14:25:19.931036+00:002022-12-26T14:25:19Z ERR  error="Unable to reach the origin service. The service may be down or it may not be responding to traffic from cloudflared: tls: first record does not look like a TLS handshake" cfRay=77fa7c337996cecc-IAD ingressRule=1 originService=https://***.***.***.***.185:9089
2022-12-26 14:25:19.931380+00:002022-12-26T14:25:19Z ERR Request failed error="Unable to reach the origin service. The service may be down or it may not be responding to traffic from cloudflared: tls: first record does not look like a TLS handshake" connIndex=3 dest=https://pihole.fakedomain.com/favicon.ico ip=***.***.***.47 type=http

Is your pihole setup for HTTPS or just HTTP?

(post deleted by author)

I’m not quite sure what you mean. When I switch the pihole tunnel in Cloudflare from HTTPS to HTTP I am unable to even access the pihole subdomain I set up. I don’t even get a 502 error. When I connect to pihole via IP address, the connection is unsecure.