AWS CloudFront + S3
Plugin to upload media files to a private s3 bucket, and serve the image using cloudfront CDN. This will allow the user to create private S3 buckets, and still be able to serve images from the bucket using CDN.
AWS S3 + CloudFront Upload
Using AWS S3 in combination with Amazon CloudFront offers several benefits over using an S3 bucket as a public content repository. You can get it working in under 2 minutes in your application. EASY!
Features
- Official AWS SDK integration
- Use PRIVATE AWS Bucket
- Adds security by creating a private bucket over a public one.
- Highly secure
Installation
# using npm
npm install @strapi/provider-upload-aws-s3
Activate the Plugin
Add the folling lines of code in the file: config/plugins.js
1module.exports = ({ env }) => ({
2 upload: {
3 config: {
4 provider: "provider-upload-aws-s3-cf",
5 providerOptions: {
6 s3Options: {
7 accessKeyId: env("AWS_ACCESS_KEY_ID"),
8 secretAccessKey: env("AWS_ACCESS_SECRET"),
9 region: env("AWS_REGION"),
10 params: {
11 signedUrlExpires: env("AWS_SIGNED_URL_EXPIRES", 15 * 60),
12 Bucket: env("AWS_BUCKET"),
13 },
14 cdn: env("AWS_CDN"),
15 },
16 },
17 },
18 },
19});
Configure the Strapi Security
Add the folling lines of code in the file: config/middlewares.js
. You can comment out or remove the existing strapi::security
from the middleware array.
1{
2 name: "strapi::security",
3 config: {
4 contentSecurityPolicy: {
5 directives: {
6 "script-src": ["'self'", "'unsafe-inline'", "cdn.jsdelivr.net"],
7 "img-src": [
8 "'self'",
9 "data:",
10 "blob:",
11 "cdn.jsdelivr.net",
12 "strapi.io",
13 `${env("AWS_BUCKET")}.s3.${env("AWS_REGION")}.amazonaws.com`,
14 `${env("AWS_CDN")}`,
15 ],
16 },
17 },
18 },
19}
Update .env
1AWS_ACCESS_KEY_ID=<>
2AWS_ACCESS_SECRET=<>
3AWS_REGION=<>
4AWS_BUCKET=<>
5AWS_CDN=<>
Report Bugs/
Any bugs/issues you may face can be submitted as issues in the Github repo.
Install now
npm install provider-upload-aws-s3-cf
Create your own plugin
Check out the available plugin resources that will help you to develop your plugin or provider and get it listed on the marketplace.