Trying to use CNAME to redirect from a subdomain to a frontend canister

Here’s what the setup looks like

Domain that I’m trying to setup:
docs.gobazzinga.io

Canister I want to redirect to:
gerhh-hiaaa-aaaah-aappq-cai.raw.ic0.app

However, this is the error I’m greeted with when I try to visit that page
image

What other things I’ve tried:

  • On Cloudflare, I’ve tried turning off proxy mode
  • I’ve tried to point the domain to both <canister_id>.ic0.app and <canister_id>.raw.ic0.app

Am I doing something wrong or is this not supposed to work like this? In case others had success redirecting their domains, please share how you’re doing it

Tagging @janeshchhabra as he suggested I post here during the Discord dev call

The boundary node needs the canister id in the request that reaches it; else it has no idea what docs.gobazzinga.io maps to. So a simple CNAME doesn’t work (unless boundary nodes start resolving CNAMEs. Maybe that would work.)

I don’t know precisely what “proxy mode” means here. A certain kind of proxying (namely one that sets the Host header to gerhh-hiaaa-aaaah-aappq-cai.raw.ic0.app) should work I think. But then, you say it doesn’t, so not sure here.

Ah, currently you are forwarding to the non-raw URL. In that case, it’s the service worker that tries to find the canister id. And because that runs in the browser, the proxy doesn’t help.

1 Like

Cloudflare:

Rules Tab then:

1 Like

What is the “$1” part for? in the canister URL?

Okay, I found the answer. For someone browsing in the future, it is to pass along the rest of the URL to the canister URL.

Cloudflare’s documentation for it lives here:

Are you adding anything to the DNS settings for the redirect rule you’ve setup here?

No, I removed most defaults.

Also yes the $1 lets you do things like:

https://dscvr.one/post/5/introducing-dscvr-a-platform-that-belongs-to-its

Which will just pass the url to the canister url.

2 Likes