-
Notifications
You must be signed in to change notification settings - Fork 406
Setup CDN on Cloud Front
Gui Talarico edited this page Sep 3, 2018
·
2 revisions
These are the steps I used to setup up a cloud front distribution, and adjusting this template to use the CND.
- Go to https://console.aws.amazon.com/cloudfront/
- Click
Create Distribution
- On the following, click "Get Started" under the Web Option.
- Configure Distribution:
- Add your domain to "Origin Domain Name"
- Leave Origin Path blank (You can use this if pointing to an S3 bucket
- Give it an Origin Id (anything you want to identify this origin)
- Set Origin Protocol Policy to "Match Viewer" (your domain might require different settings)
- Leave everything else as is.
- Click "Create Distribution"
On your vue.config.js
file, edit the baseUrl to point to your CDN in production:
baseUrl: process.env.NODE_ENV === 'production'
? 'https://d24xbrclkiXXXX.cloudfront.net' // Edit this with your distribution url
: '/',
This will setup your build js files to fetch from the CND, and in local development to fetch from your domain. Django will serve the static assets to the CDN once, but then it will be cached on the CDN and served directly from there on all subsequent requests.
Additional Resources: