Setup Workers on Personal Domain

Hi, I’m very new to server-less and learning about workers. I am getting the hang of scripting on my workers.dev subdomain in the and everything runs fine on it using the web editor… but now I want to use my personal domain using Cloudflare. What are the dns records I need to setup for it work? Do I need to setup specific dns records for each route? Can workers be used on a root domain? Using the workers editor for my personal domain just produces blank results/server not found. Sorry I know these are very basic questions… but couldn’t figure it out in the docs.

Thanks for your help!

Go to Cloudflare Dashboard -> Choose your domain -> Choose Workers tab -> Click Launch Editor. Then click on the “Routes” tab. Enter the domain you want to apply a script to + it’s route.

That’s how I assumed it would work, but I always get “This site can’t be reached & server IP address could not be found” errors when trying urls in the browser outside the editor. My routes are very basic and work when using workers.dev domain so I assumed it was something missing on my dns records for my personal domain.

Also, in the DNS panel since I have no records it says ‘An A, AAAA or CNAME record was not found pointing to the root domain. The domain will not resolve.’ so that’s another reason why it made me think that there’s something missing with my records…

You need to have a DNS record for the routes you add in the Workers tab, they won’t be automatically added. Two options until they fix it more systematically, which they are doing:

  1. A single A record pointing to a random IP. I recommend 192.0.2.1 which is a test network not used by anyone. A local IP could work as well, but not really recommended.
  2. A CNAME to a random subdomain on your domain, which doesn’t need to exist.

Make sure that this subdomains need to be :orange: for Workers to run.

6 Likes

Thank you for your help!!

No luck, error This site can’t be reached

What DNS entry needs to be created to point to the workers?

For originless workers, you can create a bogus A record with the target in the 192.0.2.0/24 range, eg 192.0.2.1, as per RFC 5737: IPv4 Address Blocks Reserved for Documentation.

For IPv6/AAAA records, anything within 2001:db8::/32 per RFC 3849: IPv6 Address Prefix Reserved for Documentation

6 Likes

I find this answer confusing.

Type = ?
Name = ?
Content = ?
TTL = ?
Proxy status = ?

Name is whatever subdomain you want the worker to affect, in my case cferror. It must be proxied.

@new2cloudflare

such as

Type = A
Name = @
Content = 192.0.2.1
TTL = Auto
Proxy status = Proxied

and

Type = AAAA
Name = @
Content = 2001:db8::
TTL = Auto
Proxy status = Proxied

replace the @ by the subdomain you want such as
app for app.mydomain.tld

1 Like

These answers are extremely confusing. Where do I find the the IP address of my Workers site? I need to know this before I can configure the DNS.

There is no IP address per se. You just put a random one (the recommended one is 192.2.0.1 which is a non four able one) and enable the proxy.

Here I am facing a same problem in connecting my sub domain to workers. My worker script is working find without domians name but with domians name it’s showing error.

Is there any video tutorial available how to connect subdomian or a url to workers.

What is the Worker showing?