DNS Settings: OpenShift with CloudFlare / rhcloud

2019-01-23 07:42发布

问题:

I am trying to set up DNS forwarding on CloudFlare, to my Openshift page (the-domain.rhcloud.com).

But when I go into the CloudFlare DNS settings and try to change the A setting, I get this error:

You entered 'the-domain.rhcloud.com' which is not a valid IP address.

It seems to be asking for a static ip address. It seems that other hosting services can provide a numerical ip address for DNS settings, but I cannot find anything like that on rhcloud / OpenShift.

How can I find my domain's ip address on rhcloud OpenShift? What should basic DNS settings look like on CloudFlare when forwarding to an rhcloud host?

Should I use any of the default A and AAAA settings from my registrar?

回答1:

It's a bit unusual, but when using services like Openshift/Heroku etc, there is no A record for the domain in your DNS. This is because there is no single A record corresponding to your site or app on the service.

If you've already set up the domain at your registrar using Cloudflare's nameservers (you need to do this!) there should be no need to do anything else at the registrar.

You need to set up one (or more) CNAMEs for the site/app at Cloudlare (if it's a website, you may want one each for e.g. example.com and www.example.com).

Assuming you do need the 'naked' domain and the www version, you'd do this:

Openshift

  1. Make sure you have domains set up for both the 'naked' domain and the www subdomain.

Cloudflare:

Back it up!

  • Cloudflare lets you export your DNS settings; do this before making any changes.

Naked domain

  1. go to the DNS settings page
  2. choose CNAME from the selector at bottom
  3. enter the-domain in the first field
  4. enter the-domain.rhcloud.com in the second ("is an alias of") field

www subdomain

  1. repeat steps 1-4 from above, but enter www for step 3.
  2. go to the "Page Rules" page
  3. add a new "page forwarding" rule that either:
    • redirects http://the-domain.com/* to http://www.the-domain.com/$1 or
    • redirects http://www.the-domain.com/* to http://the-domain.com/$1
    • choose '301' for the redirect type


回答2:

If you want your domain name to start with https://www, take a look at the steps bellow that worked for me.

Let's say we want to configure cloudflare and openshift for this domain name: example.org.

Cloudflare

DNS page

I have two records set:

  1. Type: CNAME Name: example.org Value: example-example.rhcloud.com (you should see CNAME flattening sign for this one)

  2. Type: CNAME Name: www Value: example.org

"Page rules" page

Two rules:

  1. http://www.example.org/* Settings: Always use HTTPS

  2. example.org/* Settings: Forwarding url, 301 — Permanent redirect, https://www.example.org/$1

OpenShift

Add one alias:

  • www.example.org