0

I have a website which is hosted on Amazon AWS EC2 and Domain is on 123-reg, I have pointed domain via AMAZON Elastic IP, Please see attached image, Now i want to setup CDN only for static files. How to do that? Do I need to point whole DNS on cloudways?

enter image description here

1 Answer 1

2

You can configure separate domain for static content

Login to Magento Admin and set "Base URL for Static View Files" and/or "Secure Base URL for Static View Files" in Stores > Configuration > Base URLs to the desired CDN domain, e.g. https://cdn.domain.com/static/

For base host configure CORS policy to allow access to cdn.domain.com from original domain

For example in Apache

<IfModule mod_headers.c>        
        Header set Access-Control-Allow-Origin "https://cdn.domain.com"
        Header set Access-Control-Allow-Headers "DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range"

</IfModule>

or for NGINX

location / {

        add_header 'Access-Control-Allow-Origin' 'https://cdn.domain.com';

        add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';

...

See more details here https://sherocommerce.com/setting-amazon-aws-cloudfront-cdn-magento-2/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.