How can I create a subdomain for a Cloudflare tunnel ? reddit / selfhosted ---------------------------------------------------------------------- LeVraiRoiDHyrule · 2023-12-24 01:44 Hi, I recently began my journey into Cloudflare Tunnel. I've set my tunnel to point on a subdomain server2.example.com because I already have a server on example.com. Now I want to host multiple services, all pointing to server2.example.com. When I host Home Assistant on server2.example.com, it works. But now if I create CNAME homeassistant.example.com pointing to server2.example.com, it doesn't work. I suspect it might be because of HTTP Host Header. I have set them as server2.example.com in my Tunnel settings. But I have no idea how to make it work. Could someone help me on this ? Have a great day. ---------------------------------------------------------------------- ericesev · 2023-12-24 02:05 Remove that HTTP host header feature in the tunnel settings. Then try using the CNAME. I think that should work. ---------------------------------------------------------------------- LeVraiRoiDHyrule · 2023-12-24 10:49 It doesn't work, address is unreachable. And with that setting removed, hosting on server2.website.com no longer works either, this time with a cloudflare bad gateway error. ---------------------------------------------------------------------- MadeWithPat · 2023-12-24 13:29 Do you have DNS records that point at your tunnel? You’ll have to manually create a wildcard record if you want to go that route. Alternatively, go to the configure screen for the tunnel and add subdomains in the ‘public hostname’ tab - this will create DNS entries for you (for non-wildcard hostnames), just make sure they point at Caddy. ---------------------------------------------------------------------- MadeWithPat · 2023-12-24 13:39 What do the public hostnames look like in the tunnel config? You probably want to delete your CNAME and add homeassistant.example.com to the tunnel’s public hostnames instead (pointed at Caddy) - cloudflare will create the relevant DNS record. Adding a wildcard hostname to the tunnel config instead might also work ---------------------------------------------------------------------- LeVraiRoiDHyrule · 2023-12-24 14:00 That's it !!!! I deleted my CNAME and added that subdomain in the public hostname tunnel settings instead, and it worked ! I also had to make the TLS Origin Server Name match the subdomain, and with HTTP Host Header left empty. And it works ! My plan at first was to make only one public hostname with CNAMEs pointing at it but this seems to work so I think I'll go with it. Is one solution better than the other in terms of security or practicality ? ---------------------------------------------------------------------- MadeWithPat · 2023-12-24 14:06 I imagine it’s 6 / half a dozen in terms of security. Personally I would just go this route - sometimes you’ll want to stand up a service and keep it local so you can get through the first time setup screens, then you could come back in and add it to the tunnel after it’s ready to use. I currently just have a wildcard set on the tunnel and DNS so exposing happens automatically whenever my proxy finds it (using traefik), but sounds like that might not work if you’re already using the domain elsewhere.