8

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?

Matt Lemmon
  • 169
  • 1
  • 2
  • 13

2 Answers2

10

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
bhotel
  • 472
  • 5
  • 11
  • Thank you I will try this out and let you know how it goes. – Matt Lemmon Oct 13 '14 at 18:55
  • Thanks, this helps, but it's still not working. I erased all of the default A and AAAA and MX settings which were auto-loaded by CloudFlare, so now I only have two DNS settings, which are CNAMEs for the-domain.com and www, and they are each an alias of the-domain.rhcloud.com. The nameservers are set up correctly at the host. When I visit the-domain.com it redirects me to https://the-domain.com/app and I get this error: "The page isn't redirecting properly. Firefox has detected that the server is redirecting the request for this address in a way that will never complete." – Matt Lemmon Oct 16 '14 at 00:27
  • The fact that it's getting to Openshift **at all** means the Cloudflare DNS piece is working. But the error you're describing means you have not set up the domain correctly at Openshift--see above. The request for the domain is **correctly** being routed to your Openshift app, but Openshift does not recognize the domain in the request. This is something that often happens if you add the alias `the-domain.com` to Openshift and then visit `www.the-domain.com`. So: **make sure the domain alias(es) at Openshift exactly match(es) the domain(s) you've set up in Cloudflare's DNS settings**. – bhotel Oct 16 '14 at 07:38
  • Incidentally, I've modified my answer to include using Cloudflare's export tool to back up your DNS settings prior to making changes. – bhotel Oct 16 '14 at 07:41
  • Thanks I will give it another try. – Matt Lemmon Oct 18 '14 at 13:57
  • I have given it another try. I updated the rhcloud alias and I am still getting the same problem. One point of clarification -- I don't think it is getting to Openshift. I don't know why I am getting directed to the-domain.com/app/, since there is no /app/ folder in the Openshift instance. It is a Wordpress site, so the folders are wp-admin, wp-content, and wp-includes, but there is no /app/ folder. I haven't referenced /app/ in any of the DNS settings I have changed, so I don't know why it is directing to this nonexistant folder. – Matt Lemmon Oct 19 '14 at 17:07
  • 1
    If the domain's going to `/app`, it is **positively** getting to Openshift. Webservers often redirect requests they don't understand to a default domain or other odd location. [The `/app` subdirectory redirect happens when Openshift can't appropriately route the request](http://stackoverflow.com/questions/22538185/openshift-app-redirecting-to-https-domain-name-app). The only cause of this I'm familiar with is when DNS CNAMEs and the Openshift aliases don't mach each other. If you're sure they do match, you're going to have to provide more information--the domain name would be a good start... – bhotel Oct 19 '14 at 20:44
  • Thanks, I will keep trying. The domain is mcchampions.com, and the OpenShift domain is mcchampion-garaje.rhcloud.com. It is going to be a Minecraft-related page. – Matt Lemmon Oct 23 '14 at 15:34
  • 1
    By the way I deleted all the A and AAAA and MX records from the CloudFlare DNS settings, so that the only rules are CNAME mcchampions.com is an alias of mcchampion-garaje.rhcloud.com and CNAME www is an alias of mcchampion-garaje.rhcloud.com. And I just double-checked the alias names on rhcloud, and I can't believe it--a letter was missing. I just changed it and everything works now. Thank you for your patience and assistance. I really appreciate it. – Matt Lemmon Oct 23 '14 at 15:44
  • Well, it's mostly working. Now when I go to mcchampions.com/wp-login.php I get a redirect error. I can always access WordPress admin directly on rhcloud, but I would like to get it working directly at mcchampions.com/wp-admin. – Matt Lemmon Oct 23 '14 at 15:52
  • Great that it's working. The admin redirect error is a Wordpress thing :) You'll need to change your `WordPress Address` and/or `Site Address` settings in Wordpress. – bhotel Oct 23 '14 at 21:57
  • Sounds good, I will check the WordPress Forums. Thanks again. – Matt Lemmon Oct 24 '14 at 02:13
  • Perfect answer, if you are getting too many redirects in your naked domain, make sure you configure it your naked domain in openshift also! – G. Führ May 10 '15 at 16:15
0

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
Dattaya
  • 879
  • 11
  • 15