Page Rule test before changing NS record

Hello,

I would like to transfer a domain registration to Cloudflare, but ran into difficulty with DNS and page rules, so my site broke and I had to revert to my original nameservers.

My current DNS provider has a very different way to configure URL redirection, so I’m having trouble figuring out how to accomplish the same thing with CF and also be able to test it prior to changing the NS records.

My need is extremely simple. I have a registered domain and use it for hosted Gmail. I have no problems setting up MX records.

I would simply like to have page rule that does the following:

*.example.com/* to forward to https://mail.google.com/hosted/example.com

I don’t have any A records.

How can I do this and more importantly, be able to test prior to changing NS records. I tried before and the TTL of the NS record at Cloudflare made it difficult to quickly change back after running into problems.

Thanks

Since wildcard DNS records can’t be proxied without being Enterprise, and page rules can only run on proxied DNS records, you’d probably need to set up a server just to perform the redirects.

Or, you could automate adding DNS records via the API, point them to some pointless IP (8.8.8.8) and then the page rule would take effect like that.

As for testing DNS, you can query the domain with the nameservers Cloudflare gives you before it becomes active and your changes will show up:

$ dig toontown.com @deb.ns.Cloudflare.com +short
1.5.3.4
$ dig toontown.com +short
199.181.132.250

Wildcard isn’t really necessary, I would be fine by using example.com, www.example.com and mail.example.com (that’s actually what I’m currently doing at the existing DNS server). Thought wildcard would be more streamlined, but it’s certainly not required for my purpose.

Indeed I can query DNS records, but unfortunately that won’t let me test the page rule :neutral_face:

I could probably figure out the API, but not sure what you would have me point to a pointless IP.

For a page rule to take effect, all that’s needed is any record for the DNS subdomain with an orange cloud :orange: (proxied record), so a common solution is to set it to any IP or CNAME a random website.

You would only need to use the API if you wanted a pseudo-wildcard where you just create a new record every time, but that’s not required if you don’t need it to have wildcard-like functionality.

As for testing the page rule, you could probably set the IP address given by that query in your hosts file.

Ah…Ok, let me see if understand…

Would it be correct to say that an A record with the orange cloud :orange: sets up a place to hold an http redirect (page rule)

Then, using an entry in a local hosts file with the same corresponding hostname/IP should work for testing the page rule (in this case an http redirect) ?

I don’t think you can guarantee that - it’s possible that without your NS servers pointing to Cloudflare the config may not yet be ‘active’.

Personally I’d move back to Cloudflare and work out your bugs instead of moving back and forth where you’ll get TTL and NS propagation issues. Once on Cloudflare TTL is pretty much instant (browser caching of a 301/302 is another matter) so changes and fixes can be made very quickly.

In your case you need DNS records for example.com, www.example.com, mail.example.com and a single Page Rule for:

*example.com/* to forward to https://mail.google.com/hosted/example.com

(not I’ve removed the ‘dot’ denoting only match subdomains of example.com in your pattern). The records you create for those three domains can be anything as long as you set the record to orange-cloud as no one will ever hit them (not with HTTP anyway) due to the page rule. I’d personally probably use a CNAME with a target of ghs.googlehosted.com as that’s what mail may use anyway in a non-Cloudflare world and keeping those targets will mean you’re more likely to remember what they’re for when you revisit in years time…

you had a running web server, you could do redirects at web server level instead ?

Thank you Saul and Judge…

Looks like things are going to work out.

Saul, I’m hesitant to set the NS records just yet. I did that yesterday and users seemed to have trouble for about 2 hours even after I changed it back to the original. I think records at the TLD are cached for awhile regardless of what Cloudflare does. (not quite sure how that works, but rather not risk phone calls again, if I can avoid it)

My domain went to “active” status after changing NS records to Cloudflare and stayed “active” even after going back to the original DNS server. I can query the clouflare servers and see my records, so it seems to work.

Thanks much for catching the issue with the ‘dot’. I wouldn’t have caught that on my own as it seems counterintuitive to me.

Indeed setting a dummy A record to an IP allows for page rules to work (with a corresponding entry in the hosts file for testing).

I think all the parts are working (DNS plus page rules). Now it’s just a matter of giving users some warning before updating the NS records for real.

Thanks

Eva2000, yeah…I’m trying to avoid being responsible for keeping anything, no matter how trivial, up and running :sunglasses: That’s what gmail and Cloudflare are for!

This topic was automatically closed after 31 days. New replies are no longer allowed.