Webtask

Documentation

Custom Domain Name

Use webtasks with your own custom domain name and SSL

For customized documentation and ready to run samples, please log in.

Configure your own custom domain

Auth0 Webtask runtime is normally accessible at https://webtask.it.auth0.com. You can configure access to webtasks using your own domain name by having your DNS managed by CloudFlare . Cloudfare, in an effort called Universal SSL, enables SSL by default for all their customers. We will be using the Universal SSL mechanism in Full SSL mode. This is completely free. Learn more about this here.

Use our step-by-step instructions to set up access to Auth0 webtasks via your custom domain name.

Get a custom domain

The rest of this setup assumes you own a custom domain name, you have control over the name servers this domain is configured with, and can change them to point to CloudFlare. For the purposes of this tutorial we will be using the domain serverless.host.

Set up your custom domain in CloudFlare

Create a CloudFlare account if you don't have one. Then add a new website through the CloudFlare's dashboard, specifying your custom domain name.

cloudfare-add website

Set up CNAME record from your custom domain to webtasks

Once CloudFlare finishes scanning your DNS records from your current registrar, you will have an opportunity to modify them. Add a new CNAME record that maps your custom domain, serverless.host in this example, to webtask.it.auth0.com (or whichever hostname your webtask account is using). Make sure that CloudFlare is enabled for that domain as indicated by the orange cloud in the Status column.

cloudfare-setup cname

Select a CloudFare plan

Next you will be asked which CloudFlare plan to select. Choose Free Website.

cloudfare-select plan

Switch nameservers to CloudFlare

It is time to pull the trigger. CloudFlare will provide you with new nameserver names which you need to set as the nameservers for your custom domain through your domain registrar.

cloudfare-change nameservers

The process here will be different depending what your domain registrar is. We are using NameCheap and this is what we had to do to configure the nameservers provided by CloudFlare for our custom serverless.host domain.

namecheap-set nameservers

The change of nameservers requires some time to propagate. CloudFlare dashboard will tell you when the change became effective.

Ensure Full SSL mode is selected

Back in the CloudFlare dashboard, make sure your new custom domain SSL settings are configured with Full SSL mode. This means that SSL is applied all the way from the caller, to CloudFlare, to Auth0 Webtasks.

cloudfare-full ssh

Congratulations, you have just set up custom domain access with SSL to Auth0 Webtasks!

Create a new webtask

Let's create a new webtask using the webtack cli wt. Open a terminal and use the following commands. Of course you can create your webtask based on another JavaScript file. Just skip the first command and modify the second with the valid filename.

$ echo "module.exports = function(cb) { cb(null, 'hello from my custom domain webtask'); }" > hello-custom.js
$ wt create hello-custom.js --host serverless.host

Notice the --host serverless.host argument. This argument allows the webtask to be called using your custom domain name and before running the command you should replace the value serverless.host with your own custom domain.

Note that using this option requires proof of domain ownership. The webtask runtime will validate whether the caller owns the custom domain and if not will throw an error. This validation is done by checking if a TXT record exists in the DNS of the specified custom domain. This TXT record should list the webtask container name and is a statement from the domain owner, permitting webtasks called over that custom domain name to run in a specific webtask container. An example of how TXT records look like in CloudFlare DNS management system:

cloudfare-dns-txt-records

In this example we have associated our custom domain (host = serverless.host) with two containers (ten = auth0, tjanczuk). You may create as many such TXT records as you need.

Access your webtasks

In order for a webtask to be used with a custom domain it must be created using the host parameter. This is imperative in order to validate the domain's ownership. If you have existing webtasks that you wish to use with a custom domain you will have to create them again using the host parameter.

Once created, your webtasks can be called using the following URL format: https://{custom_domain}/{container_name}/{webtask_name}/....

Note that the webtask management HTTP APIs must be invoked using the shared webtask domain name, e.g. https://webtask.it.auth0.com/api.

That's it, you are done! And remember, if you face any issues we are always available for a chat.