Custom Domain and Free SSL/TLS on Vapor Cloud

261 Views

Custom domain and free SSL/TLS on Vapor Cloud

If you are hosting your application on Vapor Cloud you might end up in a situation where you want to add your own domain, for example www.example.com and maybe even encrypt the connection with SSL/TLS.

If you havn't tried out Vapor Cloud yet, you can checkout the Quick Start.

Setup your domain

It's important you own the domain, and have control over the DNS for the domain before proceeding. To setup the domain in Vapor Cloud is quite simple. Just go to your project folder, and run:

    vapor-beta cloud create domain

Currently you need to re-deploy the application for the domain to be enabled. This will be changed in the future.

You will then be asked a couple of question. For this example, we will use www.example.com this should of cause be changed to your own domain 🙃

Setup DNS settings

Now go to your DNS provider. For the domain, setup a CNAME from www.example.com to .vapor.cloud It's important to point it to the vapor.cloud domain, since the ip addresses for the platform are dynamic, and will change.

If you have a ROOT domain if you want to setup a ROOT domain e.g. example.com you need to use an ALIAS type, this is not supported by all providers, you can for example use DNSimple for this.

After the DNS is updated, based on TTL you should be able to see your app on www.example.com

Setup SSL/TLS

Setting up SSL/TLS can be a good idea, since especially Chrome is moving toward Encrypt Everything. With Vapor Cloud you can get all of this for free. Setting it up is really simple.

Go to your project folder and run:

  vapor cloud create tls

It will first make sure the records are setup correctly. And after verify the SSL/TLS is setup on the domain. It usually takes between 30 seconds and 2 minutes, then you have HTTPS on your domain. Vapor Cloud will make sure to update the certificate automatically as it nears expiration.

This is it. You now have your own domain and HTTPS on your application 😁



Enjoy this article? Consider supporting VaporForums by following us on Twitter! Get the latest Vapor articles, tutorials, and news.