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.
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 🙃
Now go to your DNS provider. For the domain, setup a
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
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 😁