I want to register a domain (mydomain) using the registrar’s API and set CF’s DNS to the domain. Then I want to use CF’s API to add this domain, get an SSL cert and add a HTTPS redirect to TARGET.
This is my first ever domain in cloudflare, so I tried the GUI. I added the domain and the HTTPS redirect, but it does not resolve. I thought this would work like with other DNS providers that allow URL redirects, so that they add an A record for their own webserver, which then gets the cert and does redirects and URL rewrites?
Do I need to add this A record manually? What is the IP then?
Can I do this all from the CF API?
I am trying to do this without a paid server for the redirect and the TARGET might be out of my control, so just adding an A record to my domain would not work, because the TARGET won’t serve pages to mydomain requests.
I am trying to solve this for customers, who register alot of domain names. They do not pay for DNS or server fees, so can’t use Route 53 or DNSimple because of the cost involved. Both of thosewould have nice APIs though
That’s essentially what happens here as well. All you need to do is create a proxied DNS record for whatever name you want to use, and Cloudflare will replace the records IP address with their own IP.
You could really use any IP for the record, but the best practice is to create an AAAA record with
100:: as the target IP.
This can absolutely be done using the API.
Ok very nice! I will try this out right away.
I’m a java geek, so I hope I can find an API that has the correct calls implemented… Google seems to find many in github.
Thx for your speedy reply.
ke 16. elok. 2023 klo 21.11 Laudian via Cloudflare Community ([email protected]) kirjoitti:
It worked. Straight out of the box. Cannot believe this…
Added AAAA 100:: and then a CNAME www back to apex domain. Took like 3 seconds the first time. I don’t know if it gets the cert only when the first request comes or what?
If I get this all done from my code I will lie in bed and just look at the ceiling in awe. I don’t think we are in Kansas anymore!
This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.