Search code examples
meteordnsibm-cloud

How to force canonical URL in Meteor hosted on Bluemix?


I deployed a Meteor app to IBM Bluemix which created an address like myapp.mybluemix.net.

Inside Bluemix panel, since we have our own custom domain, I registered it with the address myapp.com and then I created three routes: myapp.mybluemix.net, myapp.com and www.myapp.com. I also created an enviroment variable ROOT_URL = 'www.myapp.com', since we want the www. version to be used instead of the naked domain.

Inside the DNS provider panel, I put a CNAME record as www.myapp.com CNAME myapp.mybluemix.net and a A record as myapp.com A XXX.XXX.XXX.XXX (pointing to the public IP of Bluemix host).

With all these, my app was opening well, but with duplicated URLs. Then I discovered the Canonical package and republished my app with it included hoping to solve the canonical need.

Unfortunately, all requests both to myapp.com and www.myapp.com redirects to myapp.mybluemix.net!

I can't see what configuration is causing this problem. What of the described steps I went wrong?


Solution

  • Following steps helped me configure canonical URL :

    1) Install the canonical meteor package

    2) Configure two routes to your application (naked and www subdomain)

    enter image description here

    3) Set CF environment variable : cf set-env leadershipboard ROOT_URL "http://www.vamsee.ml"

    4) Configure DNS server CNAME to route traffic to Bluemix application : enter image description here

    5) Use slightly modified meteor buildpack : https://github.com/JProgrammer/cf-meteor-buildpack

    Hope it helps.