TODO: setup SSL.
This is a quick guide on how to setup domain and infinite subdomains, in a case where, for example, you may have one subdomain for each client.
Starting from this http://stackoverflow.com/a/39646701
Unfortunately, ALIAS records are not used by Gandi, and A records are not available for use with Heroku because Heroku does not use fixed IP addresses. So we have to use www.mydomain.com
as base url instead of mydomain.com
and set up a redirect from the root domain to the www.
version.
through their CLI (because the internet says their web interface is broken, I don't know if it's accurate), type:
heroku domains:add mydomain.com --app my-app
and
heroku domains:add *.mydomain.com --app my-app
-
Use the Gandi default DNS servers
-
Edit the zone file to be:
@ 10800 IN A 217.70.184.38 * 10800 IN CNAME wildcard.mydomain.com.herokudns.com. www 10800 IN CNAME mydomain.com.herokudns.com.
Note that the trailing . is required
-
Set web forwarding for the domain:
The type of forwarding will be 'direct (permanent)', leave the subdomain blank, and set the forwarding address as
www.mydomain.com
Using Node.js and Express, create a middleware that checks for the subdomains
app.use(function(req, res, next) {
var domains = req.subdomains;
if (/* condition */) {
// your code
req.url = '/something' + req.url;
}
else {
// your code
return res.redirect(somewhere);
}
next();
});
Hey @GarryOne
I tried what you said, I added a bare domain to heroku and in gandi, I was pointing it to WIX, so I reset the Nameservers and it gave default DNS Configuration but when I try to add ALIAS it gives me a warning "ALIAS record cannot be used along with A or AAAA records for @" . Do I delete the A record?