> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify-mintlify-75458a71.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# AWS Route 53 and CloudFront

> Deploy your Mintlify documentation at a subpath on AWS using Route 53 for DNS routing and CloudFront as a CDN with Lambda@Edge functions.

To host your documentation at a subpath such as `yoursite.com/docs` using AWS Route 53 and CloudFront, you must configure your DNS provider to point to your CloudFront distribution.

## Overview

Route traffic to these paths with a Cache Policy of **CachingDisabled**:

* `/.well-known/acme-challenge/*` - Required for Let's Encrypt certificate verification
* `/.well-known/vercel/*` - Required for domain verification
* `/docs/*` - Required for subpath routing
* `/docs/` - Required for subpath routing

Route traffic to this path with a Cache Policy of **CachingEnabled**:

* `/mintlify-assets/_next/static/*`
* `Default (*)` - Your website's landing page

All Behaviors must have an **origin request policy** of `AllViewerExceptHostHeader`.

<img src="https://mintcdn.com/mintlify-mintlify-75458a71/__Q24dP7cDEwScxD/images/cloudfront/all-behaviors.png?fit=max&auto=format&n=__Q24dP7cDEwScxD&q=85&s=3619c27683eb71507b3012789ee591e6" alt="CloudFront &#x22;Behaviors&#x22; page with 4 behaviors: /docs/*, /docs, Default, and /.well-known/*." width="1603" height="365" data-path="images/cloudfront/all-behaviors.png" />

## Create CloudFront distribution

1. Navigate to [CloudFront](https://aws.amazon.com/cloudfront) inside the AWS console.
2. Click **Create distribution**.

<Frame>
  <img src="https://mintcdn.com/mintlify-mintlify-75458a71/__Q24dP7cDEwScxD/images/cloudfront/create-distribution.png?fit=max&auto=format&n=__Q24dP7cDEwScxD&q=85&s=caed5fe38c774873e661d6575491b882" alt="CloudFront Distributions page with the &#x22;Create distribution&#x22; button emphasized." width="3024" height="922" data-path="images/cloudfront/create-distribution.png" />
</Frame>

3. For the Origin domain, input `[SUBDOMAIN].mintlify.site` where `[SUBDOMAIN]` is your project's unique subdomain.

<Frame>
  <img src="https://mintcdn.com/mintlify-mintlify-75458a71/__Q24dP7cDEwScxD/images/cloudfront/origin-name.png?fit=max&auto=format&n=__Q24dP7cDEwScxD&q=85&s=0a9d06292160219a035b49967f5cd370" alt="CloudFront &#x22;Create distribution&#x22; page showing &#x22;acme.mintlify.site&#x22; as the origin domain." width="1495" height="1036" data-path="images/cloudfront/origin-name.png" />
</Frame>

4. For "Web Application Firewall (WAF)," enable security protections.

<Frame>
  <img src="https://mintcdn.com/mintlify-mintlify-75458a71/__Q24dP7cDEwScxD/images/cloudfront/enable-security-protections.png?fit=max&auto=format&n=__Q24dP7cDEwScxD&q=85&s=d5e215fdb59bdb2f12bcf41fb6a72a66" alt="Web Application Firewall (WAF) options with &#x22;Enable security protections&#x22; selected." width="1482" height="877" data-path="images/cloudfront/enable-security-protections.png" />
</Frame>

5. The remaining settings should be default.
6. Click **Create distribution**.

## Add default origin

1. After creating the distribution, navigate to the "Origins" tab.

<Frame>
  <img src="https://mintcdn.com/mintlify-mintlify-75458a71/__Q24dP7cDEwScxD/images/cloudfront/origins.png?fit=max&auto=format&n=__Q24dP7cDEwScxD&q=85&s=9fc64e26978f4071c019d389befa1927" alt="A CloudFront distribution with the &#x22;Origins&#x22; tab highlighted." width="3024" height="1466" data-path="images/cloudfront/origins.png" />
</Frame>

2. Find your staging URL that mirrors the main domain. This varies depending on your landing page host. For example, the Mintlify staging URL is [mintlify-landing-page.vercel.app](https://mintlify-landing-page.vercel.app).

<Info>
  If Webflow hosts your landing page, use Webflow's staging URL. It would look like `.webflow.io`.

  If you use Vercel, use the `.vercel.app` domain available for every project.
</Info>

3. Create a new Origin and add your staging URL as the "Origin domain."

<Frame>
  <img src="https://mintcdn.com/mintlify-mintlify-75458a71/__Q24dP7cDEwScxD/images/cloudfront/default-origin.png?fit=max&auto=format&n=__Q24dP7cDEwScxD&q=85&s=8dc1d9e3f77edcbc918c706340b3a19f" alt="CloudFront &#x22;Create origin&#x22; page with a &#x22;Origin domain&#x22; input field highlighted." width="3024" height="1332" data-path="images/cloudfront/default-origin.png" />
</Frame>

By this point, you should have two Origins: one with `[SUBDOMAIN].mintlify.site` and another with your staging URL.

<Frame>
  <img src="https://mintcdn.com/mintlify-mintlify-75458a71/__Q24dP7cDEwScxD/images/cloudfront/final-origins.png?fit=max&auto=format&n=__Q24dP7cDEwScxD&q=85&s=eb6ae98f74836e2c9a19c94237bb9b51" alt="CloudFront &#x22;Origins&#x22; page with two origins: One for mintlify and another for mintlify-landing-page." width="1230" height="690" data-path="images/cloudfront/final-origins.png" />
</Frame>

## Set behaviors

Behaviors in CloudFront enable control over the subpath logic. At a high level, you create the following logic:

* **If a user lands on your custom subpath**, go to `[SUBDOMAIN].mintlify.site`.
* **If a user lands on any other page**, go to the current landing page.

1. Navigate to the "Behaviors" tab of your CloudFront distribution.

<Frame>
  <img src="https://mintcdn.com/mintlify-mintlify-75458a71/__Q24dP7cDEwScxD/images/cloudfront/behaviors.png?fit=max&auto=format&n=__Q24dP7cDEwScxD&q=85&s=b92f5258528d7c229010a3fd74efca1f" alt="CloudFront &#x22;Behaviors&#x22; tab highlighted." width="3024" height="1384" data-path="images/cloudfront/behaviors.png" />
</Frame>

2. Click the **Create behavior** button and create the following behaviors.

### `/.well-known/*`

Create behaviors for Vercel domain verification paths with a **Path pattern** of `/.well-known/*` and set **Origin and origin groups** to your docs URL.

For "Cache policy," select **CachingDisabled** to ensure these verification requests pass through without caching.

<Frame>
  <img src="https://mintcdn.com/mintlify-mintlify-75458a71/__Q24dP7cDEwScxD/images/cloudfront/well-known-policy.png?fit=max&auto=format&n=__Q24dP7cDEwScxD&q=85&s=905345c1dc3be7d57bcb6294c5a39da1" alt="CloudFront &#x22;Create behavior&#x22; page with a &#x22;Path pattern&#x22; of &#x22;/.well-known/*&#x22; and &#x22;Origin and origin groups&#x22; pointing to the staging URL." width="1413" height="1098" data-path="images/cloudfront/well-known-policy.png" />
</Frame>

<Info>
  If `.well-known/*` is too generic, you can narrow it down to 2 behaviors at a minimum for Vercel:

  * `/.well-known/vercel/*` - Required for Vercel domain verification
  * `/.well-known/acme-challenge/*` - Required for Let's Encrypt certificate verification
</Info>

### Your subpath

Create a behavior with a **Path pattern** of your chosen subpath, for example `/docs`, with **Origin and origin groups** pointing to the `.mintlify.site` URL (for example, `acme.mintlify.site`).

* Set "Cache policy" to **CachingOptimized**.
* Set "Origin request policy" to **AllViewerExceptHostHeader**.
* Set Viewer Protocol Policy to **Redirect HTTP to HTTPS**

<Frame>
  <img src="https://mintcdn.com/mintlify-mintlify-75458a71/__Q24dP7cDEwScxD/images/cloudfront/behavior-1.png?fit=max&auto=format&n=__Q24dP7cDEwScxD&q=85&s=aee3854c8e2cf8e8c0ad0a6819cdcca9" alt="CloudFront &#x22;Create behavior&#x22; page with a &#x22;Path pattern&#x22; of &#x22;/docs/*&#x22; and &#x22;Origin and origin groups&#x22; pointing to the acme.mintlify.site URL." width="1520" height="1117" data-path="images/cloudfront/behavior-1.png" />
</Frame>

### Your subpath with wildcard

Create a behavior with a **Path pattern** of your chosen subpath followed by `/*`, for example `/docs/*`, and **Origin and origin groups** pointing to the same `.mintlify.site` URL.

These settings should exactly match your base subpath behavior. With the exception of the **Path pattern**.

* Set "Cache policy" to **CachingOptimized**.
* Set "Origin request policy" to **AllViewerExceptHostHeader**.
* Set "Viewer protocol policy" to **Redirect HTTP to HTTPS**

### `/mintlify-assets/_next/static/*`

* Set "Cache policy" to **CachingOptimized**
* Set "Origin request policy" to **AllViewerExceptHostHeader**
* Set "Viewer protocol policy" to **Redirect HTTP to HTTPS**

### `Default (*)`

Lastly, edit the `Default (*)` behavior.

<Frame>
  <img src="https://mintcdn.com/mintlify-mintlify-75458a71/__Q24dP7cDEwScxD/images/cloudfront/default-behavior-1.png?fit=max&auto=format&n=__Q24dP7cDEwScxD&q=85&s=f877ce9c4f23288915b2434179931e3b" alt="A CloudFront distribution with the &#x22;Default (*)&#x22; behavior selected and the Edit button emphasized." width="3024" height="1406" data-path="images/cloudfront/default-behavior-1.png" />
</Frame>

1. Change the default behavior's **Origin and origin groups** to the staging URL (for example, `mintlify-landing-page.vercel.app`).

<Frame>
  <img src="https://mintcdn.com/mintlify-mintlify-75458a71/__Q24dP7cDEwScxD/images/cloudfront/default-behavior-2.png?fit=max&auto=format&n=__Q24dP7cDEwScxD&q=85&s=81662cc8fc68de809838b56fa0fe900f" alt="CloudFront &#x22;Edit behavior&#x22; page with the &#x22;Origin and origin groups&#x22; input field highlighted." width="3024" height="1298" data-path="images/cloudfront/default-behavior-2.png" />
</Frame>

2. Click **Save changes**.

### Check that you set up behaviors correctly

If you follow the preceding steps, your behaviors should look like this:

<Frame>
  <img src="https://mintcdn.com/mintlify-mintlify-75458a71/__Q24dP7cDEwScxD/images/cloudfront/all-behaviors.png?fit=max&auto=format&n=__Q24dP7cDEwScxD&q=85&s=3619c27683eb71507b3012789ee591e6" alt="CloudFront &#x22;Behaviors&#x22; page with 4 behaviors: /docs/*, /docs, Default, and /.well-known/*." width="1603" height="365" data-path="images/cloudfront/all-behaviors.png" />
</Frame>

## Preview distribution

You can now test whether you set up your distribution properly by going to the "General" tab and visiting the **Distribution domain name** URL.

<Frame>
  <img src="https://mintcdn.com/mintlify-mintlify-75458a71/__Q24dP7cDEwScxD/images/cloudfront/preview-distribution.png?fit=max&auto=format&n=__Q24dP7cDEwScxD&q=85&s=cab1c1beb3207e6449052d3e22c81619" alt="CloudFront &#x22;General&#x22; tab with the &#x22;Distribution domain name&#x22; URL highlighted." width="3024" height="1394" data-path="images/cloudfront/preview-distribution.png" />
</Frame>

All pages should be directing to your main landing page, but if you append your chosen subpath, for example `/docs`, to the URL, you should see it going to your Mintlify documentation instance.

## Connect with Route 53

Now, bring the capabilities of the CloudFront distribution into your primary domain.

<Note>
  For this section, you can also refer to AWS's official guide on [Configuring
  Amazon Route 53 to route traffic to a CloudFront
  distribution](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/routing-to-cloudfront-distribution.html#routing-to-cloudfront-distribution-config)
</Note>

1. Navigate to [Route53](https://aws.amazon.com/route53) inside the AWS console.
2. Navigate to the "Hosted zone" for your primary domain.
3. Click **Create record**.

<Frame>
  <img src="https://mintcdn.com/mintlify-mintlify-75458a71/__Q24dP7cDEwScxD/images/cloudfront/route53-create-record.png?fit=max&auto=format&n=__Q24dP7cDEwScxD&q=85&s=85ee4186858052c80db8a9990193d78a" alt="Route 53 &#x22;Records&#x22; page with the &#x22;Create record&#x22; button emphasized." width="1540" height="1238" data-path="images/cloudfront/route53-create-record.png" />
</Frame>

4. Toggle `Alias` and then **Route traffic to** the `Alias to CloudFront distribution` option.

<Frame>
  <img src="https://mintcdn.com/mintlify-mintlify-75458a71/__Q24dP7cDEwScxD/images/cloudfront/create-record-alias.png?fit=max&auto=format&n=__Q24dP7cDEwScxD&q=85&s=1f4f215c35921c68d9df523485d1c9e2" alt="Route 53 &#x22;Create record&#x22; page with the &#x22;Alias&#x22; toggle and the &#x22;Route traffic to&#x22; menu highlighted." width="3024" height="1494" data-path="images/cloudfront/create-record-alias.png" />
</Frame>

5. Click **Create records**.

<Note>
  You may need to remove the existing A record if one currently exists.
</Note>

Your documentation is now live at your chosen subpath for your primary domain.

<Note>
  After configuring your DNS, custom subdomains are usually available within a few minutes. DNS propagation can sometimes take 1-4 hours, and in rare cases up to 48 hours. If your subdomain is not immediately available, wait before troubleshooting.
</Note>
