Where to find my site's IP Address for setting up sub-domain
When configuring a sub-domain where do I get the IP Address for my website? I am using Cloudflare Pages so the top level domain is aliased to the
*.pages.dev
instance. I just don't know where to find this so that I can properly route the traffic. Been scanning through the docs but not finding anything here either. Anyone know where that can be found?23 Replies
Adding a custom domain for your Pages Project requires a CNAME record, not an A/AAAA record. Firstly, is your custom domain on Cloudflare?
@HardAtWork Yep bought my domain through Cloudflare so it's in-house. The CNAME is setup to be the custom domain aliased to the
*pages.dev
and then what I am trying to do is setup a sub-domain for blog.my-site.com
I have the Page Rule working for the redirect when /blog/*
is encountered
I just don't know where to get this IP address that the documentation keeps referencingWhich documentation is that? Can you link me to it?
yep one second
Create subdomain · Cloudflare DNS docs
Most subdomains serve a specific purpose within the overall context of your website. For example, blog.example.com might be your blog, …
Ok, and just to make sure, do you want the blog to be visible on
blog.my-site.com
yep the index as well as all the routes pertaining to it
never worked with sub-domains before so learning curve is pretty high and I'm not networking guru either
Go to https://dash.cloudflare.com/?to=/:account/pages/view/:pages-project/domains, and
Set up a custom domain
. For the actual domain, put in blog.my-site.com
, and then it should start doing the work for you.Okay got that setup so that now the DNS for the custom domain is the
my-site.com --> my-site.pages.dev
and the Pages has two custom domains
my-site.com --> my-site.pages.dev
blog.my-site.com --> my-site.pages.dev
The Page Rule that I have is
my-site.com/blog* --> blog.my-site.com
Currently I'm getting back Error 1016 "Origin DNS Error" when I try to visit the blog.my-site.com
Does the DNS for the custom domain still need an A record that points the sub-domain back at the my-site.pages.dev
?Is the Page Rule supposed to redirect people to the blog?
Because right now, the root and the subdomain are serving the same content
Yes, from my understanding DNS doesn't know anything about the route in a URL so if someone visits
my-site.com
and clicks to go to the blog the app is going to go to /blog
but DNS is just going to go to my-site.com/blog
not the sub-domain so I added the Page Rule to redirect.
ahhh okay I think I understand I didn't really say what I am trying to achieve well.
my-site.com
my-site.com/about
my-site.com/abc
All live at my-site.com
But I want to scope all the blog to blog.my-site.com
so all the routes including the index for /blog
should live at that sub-domain
sorry I didn't convey that wellYou can do that. The issue is, right now anyway,
blog.my-site.com
is serving the exact same content as my-site.com
, which I assume you don't want?yep initially with my little understanding of this I was trying to point
blog.my-site.com
at my-site.pages.dev/blog
but clearly that doesn't work
it's all the same AstroJS appThe easiest way to get that to work the way I think you want it to is to break the blog off into its own Astro App
okay, so if I did that how do I get Cloudflare to recognize that it's two different application?
Is it possible to do this as one application?
Not really easily. The easiest thing would be to have all off the content on a single site:
my-site.com
, my-site.com/about
, my-site.com/abc
, & my-site.com/blog
. Trying to split blog
off into its own domain, without it actually being a separate app, is quite difficult(and I'm not actually sure if you are able to do that without Workers).okay I think I understand. It's been difficult to map out in my head how the DNS side of this works and that's probably the issue. So when it comes to using Cloudflare Pages I normally just connect to project via GitHub and setup the build to execute on push to production. Would this be separated into 2 separate Pages apps and then setup the custom domains as mentioned above?
No. If you want the
blog
to be on its own domain, you would need a separate Github Repo for the blog
project, create a separate Pages project for it, and then connect the custom domain.
I wouldn't recommend keeping both in the same repo.okay makes sense now, thanks for all your help understanding this better. I really appreciated it. Do you have any recommendations on reading for better understanding DNS/sub-domains/etc. I am realizing this is a pretty big question mark for me when it comes to understanding what's happening behind the scenes.
Cloudflare
What is DNS? | How DNS works | Cloudflare
DNS, or the domain name system, is the phonebook of the Internet, connecting web browsers with websites. Learn more about how DNS works and what DNS servers do.
not necessarily Cloudflare but in general. I will read that as well
This is a more general learning guide. It may tell you about how CF products can help you with certain things, but it should also give you a grounding in how DNS itself works, or at least how you use it.
thanks so much I really appreciate all the help!