Custom domain
Set a custom domain for each of your service to let users reach them using your brand’s domain. Say,
app.your-awesome-site.com
.
Here is how you can set it up.
Steps
1. Add your domain
- Navigate to the specific environment dashboard (from Environments section)
- Click on Services tab to see all services
- In the Service dashboard, navigate to “Custom domain” tab.
- Enter your new domain and click save.
Clicking “Save” button will give you DNS records to add to your domain DNS settings.
In next step, we will use these DNS records to verify the ownership of your domain and to route traffic from your domain to your environment.
2. Verify your domain - Add CNAME records:
In this step you will verify the ownership of your domain by adding the CNAME records you see in above step.
Go to your DNS registrar > DNS Zone and add the given CNAME records.
After saving the DNS settings, it takes few minutes for the newly added DNS settings to propagate. Sometimes it may also take up to 24 hours.
3. Deploy
Once you have added the given CNAME records to your domain’s DNS settings give it a few minutes for the DNS settings to propagate. Then, come back to Service > Custom domain settings page, and click on “Verify and deploy” button.
If domain verification fails then give it few more minutes for the newly updated DNS settings to propagate and try again. If it still fails then check whether you have properly configured the given CNAME records in your domain’s DNS settings.
LocalOps will then
- configure your service to run on the custom domain you added and
- auomatically provison a brand new auto-renewing SSL Certificate for the custom domain
You can now reach your service using the new domain.
Access current domain
For your code/service to start reading the new domain, trigger a new deployment on your service. Either by pressing “Deploy” button in the service settings section. Or push a new commit on configured branch of the service.
During this deployment, LocalOps fills environment variable LOPS_SVC_HOST
with the current active domain.
You can access this in your app (say NodeJS app) like