Route domain to godaddy hosting and subdomain to VPS

I have a domain bought from godaddy. I also have webhosting and a PHP website hosted on godaddy. I have changed the nameservers and configured site with cloudflare. Now I want to add a subdomain and route it to VPS server. I am not sure how to do it.

Example

  • www.example.com should route users to website hosted on godaddy
  • app.example.com should route users to my VPS where I have an application hosted on tomcat

Add DNS records for www and app in your Cloudflare DNS here…
https://dash.cloudflare.com/?to=/:account/:zone/dns/records

Use the relevant A, AAAA or CNAME values for each to point at Godaddy for www and your VPS for app.

I tried that but app.example.com is not taking me to vps. Atached are the settings. Can you check if I am doing it right

www, through its CNAME appears to be pointing to the same IP address as app - you said they were to go do different places.

www should point to Godaddy’s CNAME or IP address.
api should point at your VPS IP address.

Sorry. I was doing some hit and trial. So, those IP addresses are the same. However, I identified the issue.

The problem is SSL. My VPS does not have SSL. So, when encryption mode is FULL

And when encryption mode is Flexible

Any solution that you can suggest?

Add SSL to your VPS and use only “Full (strict)”. Using Cloudflare with “Flexible” means traffic is unencrypted between Cloudflare and your origin even if HTTPS is used by the client so is unsecure (and deceives your site users that their data is secured). “Flexible” is a legacy mode from when SSL certificates were expensive, but these days with LetsEncrypt or Cloudflare origin certificates being free, there’s no reason to do this, you should be secure end-to-end.

2 Likes