AWS Route 53 and CloudFront - GrackerAI Portal
Host your GrackerAI portal at a /portal
subdirectory using AWS services to map gracker.ai/portal
to portal.pseo.one
.
Create CloudFront Distribution
Navigate to CloudFront (opens in a new tab) inside the AWS console and click on Create distribution.
For the Origin domain, input portal.pseo.one
where your portal is currently deployed. Click on Use: portal.pseo.one.
portal.pseo.one
For Cache key and origin requests, select Caching Optimized.
For Web Application Firewall (WAF), enable security protections.
The remaining settings should be default. Click Create distribution.
Add Default Origin
After creating the distribution, navigate to the Origins tab.
We need to add your main GrackerAI website as the default origin. This should be where your main gracker.ai
domain currently points to.
For instance, if your main website is hosted on:
- Vercel: Use your
.vercel.app
domain - Netlify: Use your
.netlify.app
domain - Custom hosting: Use your current hosting URL
Create a new Origin and add your main website URL as the Origin domain.
By this point, you should have two Origins:
portal.pseo.one
(for the portal)- Your main website origin (for everything else)
Set Behaviors
Behaviors in CloudFront enable control over the subpath logic. We're creating the following routing logic:
- If a user visits
/portal/*
, route toportal.pseo.one
- If a user visits any other page, route to your main GrackerAI website
Create three behaviors by clicking the Create behavior button.
/portal/*
The first behavior should have a Path pattern of /portal/*
with Origin and origin groups pointing to portal.pseo.one
.
Path pattern: /portal/*
Origin: portal.pseo.one
For Cache policy, select CachingOptimized and create behavior.
/portal
The second behavior should be the same as the first one but with a Path pattern of /portal
and Origin and origin groups pointing to the same portal.pseo.one
.
Path pattern: /portal
Origin: portal.pseo.one
Default (*)
Edit the Default (*) behavior to change the Origin and origin groups to your main GrackerAI website origin.
This ensures all traffic not matching /portal
or /portal/*
goes to your main website.
Click Save changes.
Preview Distribution
Test your distribution by going to the General tab and visiting the Distribution domain name URL.
- All pages should direct to your main GrackerAI website
- Appending
/portal
to the URL should route to your portal atportal.pseo.one
Connecting with Route53
Now we'll connect the CloudFront distribution to your primary gracker.ai
domain.
Navigate to Route53 (opens in a new tab) in the AWS console, and click into the Hosted zone for gracker.ai
. Click Create record.
For the root domain (gracker.ai):
- Leave Record name blank
- Toggle Alias on
- Select Route traffic to → Alias to CloudFront distribution
- Choose your CloudFront distribution from the dropdown
- Click Create records
For www subdomain (optional):
- Enter
www
in Record name - Toggle Alias on
- Select Route traffic to → Alias to CloudFront distribution
- Choose your CloudFront distribution from the dropdown
- Click Create records
You may need to remove existing A records if they currently exist.
SSL Certificate (Important)
To use a custom domain with CloudFront, you need an SSL certificate:
- Go to AWS Certificate Manager in the US East (N. Virginia) region
- Click Request a certificate
- Choose Request a public certificate
- Add domain names:
gracker.ai
www.gracker.ai
- Choose DNS validation
- Add the CNAME records to your Route53 hosted zone for validation
- Once validated, go back to your CloudFront distribution
- Edit the distribution and select your certificate under Custom SSL certificate
Testing
After DNS propagation (can take up to 48 hours), you should be able to:
- Visit
gracker.ai
→ See your main GrackerAI website - Visit
gracker.ai/portal
→ Be routed to your portal atportal.pseo.one
- Visit
gracker.ai/portal/any-page
→ Be routed to portal pages
Troubleshooting
Common issues:
- 502 Bad Gateway: Check that
portal.pseo.one
is accessible and accepts requests with theHost
header set togracker.ai
- SSL errors: Ensure your certificate includes both
gracker.ai
andwww.gracker.ai
- Caching issues: CloudFront caches responses. Use the Invalidations tab to clear cache during testing
- Origin headers: Your portal at
portal.pseo.one
may need to be configured to accept requests from the CloudFront distribution
Cache invalidation: To clear CloudFront cache during testing:
- Go to your distribution's Invalidations tab
- Click Create invalidation
- Enter
/portal/*
to clear portal cache or/*
for everything