publish_date | title | description | authors | image | categories | tags | excerpt_separator |
---|---|---|---|---|---|---|---|
2025-03-21 |
How to set up a Custom Domain for FusionAuth using AWS CloudFront |
Learn how to use AWS CloudFront to Setup a Custom Domain with FusionAuth. |
Mark Robustelli |
/img/blogs/cloudfront/configure-custom-domain-in-cloudfront.png |
Tutorial |
custom-domain, aws, cloudfront, domain-name |
{/* more */} |
import Aside from '/src/components/Aside.astro'; import InlineField from 'src/components/InlineField.astro'; import InlineUIElement from 'src/components/InlineUIElement.astro'; import Breadcrumb from 'src/components/Breadcrumb.astro';
While you configure a custom domain with a FusionAuth Hosting package, you can also configure one using AWS Cloudfront.
{/* more */}
One of the great things about FusionAuth is its flexibility. FusionAuth wants you to be able to control your auth and run it the way that works best for you. If AWS CloudFront is your chosen tool for your domain management, you should and can manage how users access your instance of FusionAuth from there.
For the purpose of this blog, pretend you own a software company named Code Gremlins. Code Gremlins offers a web based ToDo app to customers. You have a hosted instance of FusionAuth and want to configure AWS CloudFront to access that instance.
- Your FusionAuth hosted instance is available at the following URL: https://codegremlins.fusionauth.io.
- You own the company domain of codegremlins.net and it is registered with GoDaddy.
- You want to reference your FusionAuth instance using https://auth.codegremlins.net.
- You can offer your application at https://todoapp.codegremlins.net.
Cloudfront requires an SSL certificate from AWS Certificate Manager (ACM) if you want to serve traffic securely (which you do). Here's how to get one:
- Go to AWS Certificate Manager and click the Sign In or Sign in to the Console button.
- Once at the Console, enter
Certificate Manager
in the search bar.
- Go back to the AWS console and search for CloudFront. Select CloudFront.
Now you will have to make a change to allow the proper headers.
- Next, click on the Behaviors tab.
- Choose
Default(*)
. - Select Edit
- Scroll down to the
Cache key and origin requests
section. - Change the Cache policy to
CachingDisabled
. - Change the Origin request policy to
AllViewerExceptHostHeader
. - Select Save changes.
Now that you have the distribution set up, you need to tell the DNS to point to the distribution when a user enters auth.codegremlins.net
.
- Go to your domain provider. In this case, GoDaddy.
- Go to
My Products
. - Select
Domains
. - Select
codegremlins.net
. - Click on the DNS tab.
- Click Add New Record.
- Choose
CNAME
for the Type. - Enter
auth
for the Name. - Value is the name of the AWS Distribution domain name. In this case, Name will be
d2gwcywxndug73.cloudfront.net
. - Click Save.
Open your browser and visit https://auth.codegremlins.net. You should get the FusionAuth Admin UI web page.
At this point, you should be able to use https://auth.codegremlins.net as you would the original https://codegremlins.fusionauth.io address. It will work with your applications and the APIs. You can also use these steps to create additional domains for additional applications.
There are also several other settings in the AWS Distribution set up and you can tweak them until they work just right for you. After all, that is one of the beautiful parts about owning your authentication. You get to set it up so that it works just for your needs. FusionAuth gives you that flexibility.