# Hosting on custom domain

In order to 'host' your Web App on a custom domain, the following is required:

* A domain, as well as access to the domain's DNS settings.
* A published Web App, either Preview or Production.

As you may have noticed, 'host' is written in parentheses. This is because this article does not explain how to actually host the Web App on your own domain, but how you can make it appear as if your Web App is hosted on your own domain. The way we're going to achieve this is by adding either a CNAME or ALIAS record to your domain's DNS settings.

Before we start, let's first explain the terms CNAME and ALIAS so that you have a better understanding of what we're doing here.

### 'Hosting' via CNAME

CNAME records can be used to alias one name to another. Take for example these two URLs:

URL #1: `appmachine.com` \
URL #2: `www.appmachine.com`&#x20;

Both addresses point toward the same application and are hosted by the same server. However, only `appmachine.com` points towards the server IP address. The prefix (subdomain) to the other URL `www.` is actually a CNAME record that points towards `appmachine.com`.&#x20;

Now, let's say we've created a Web App with AppMachine which is published on the URL `1234ab.myinstant.app`. If we create a CNAME record for `webapp.` within the appmachine.com DNS settings, and point it towards `1234ab.myinstant.app`, then we will be able to view our published web app by navigating to the URL `webapp.appmachine.com`.

### **'Hosting' via ALIAS**

An ALIAS provides CNAME-like behaviour, but does so on the apex domain rather than on the subdomain.

<img src="https://2636455530-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2wzy1sO41plYrfJfaAhN%2Fuploads%2FbcWvhMzi2t62qAjxNUe7%2Fimage.png?alt=media&#x26;token=4d3df56e-e62c-4d13-a4f4-79ec42fabfd3" alt="" data-size="original">

Let's say we have our published Web App `1234ab.myinstant.app` again, and this time, instead of `webapp.appmachine.com`, we want `appmachine.com` to display the published Web App. Because we want to point the apex domain toward a different domain, we use an ALIAS with the name `appmachine.com` and point it towards `1234ab.myinstant.app`.

### When to use which?

Generally speaking, if you've bought a domain for the sole purpose if displaying your Web App, and you wish for your app to visible on the apex domain URL, then you'll use an ALIAS to accomplish this.

If you already have a website and you wish to make your Web App available via a subdomain on the same URL, then you use a CNAME to accomplish this.

### Linking your domain

To link your domain to your AppMachine Web App, open the Web App info page in AppMachine and click the 'Link custom domain' button.

<figure><img src="https://2636455530-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2wzy1sO41plYrfJfaAhN%2Fuploads%2FTThiuQnQETGqps5qng9w%2FPasted_Image_27_10_2022__16_21-2.png?alt=media&#x26;token=8c9dc9ff-0bdc-4d65-9ebd-ffcd0d3a06a8" alt=""><figcaption></figcaption></figure>

Next, enter the domain on which you'd like the Web App to become visible. This can be a subdomain if you'll be using a CNAME-record, or the apex domain if you're using an ALIAS.

<figure><img src="https://2636455530-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2wzy1sO41plYrfJfaAhN%2Fuploads%2F6cIcb8RDh8NEj4TcAqVj%2Fimage.png?alt=media&#x26;token=d5c1a796-4c28-4649-bd46-52d756b4e6fd" alt=""><figcaption></figcaption></figure>

Finally, login to your domain's control panel and open the DNS settings page. Depending on your choosing, add either a CNAME or an ALIAS to your DNS settings with the record name and value displayed in AppMachine.

<figure><img src="https://2636455530-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2wzy1sO41plYrfJfaAhN%2Fuploads%2FvR1FqIeqEdGaeDs3lGcI%2Fimage.png?alt=media&#x26;token=1d99d637-fd3d-437e-8ec8-421cfe0d5fd0" alt=""><figcaption></figcaption></figure>

After clicking the Finish button, our systems will check whether the domain you've provided can be reached, and whether the references have been configured correctly. If everything checks out, the Custom DNS status on your Web App info page will state 'Linked'.

<figure><img src="https://2636455530-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2wzy1sO41plYrfJfaAhN%2Fuploads%2FUsSMyJRJURYNkou67Izl%2FPasted_Image_27_10_2022__16_36.png?alt=media&#x26;token=2ca58b08-4dc2-40e7-b503-35437395c03e" alt=""><figcaption></figcaption></figure>
