• Resolved Megunticook

    (@megunticook)


    Can anyone point me to a good tutorial on setting up TotalCache with AWS CloudFront using origin push to an S3 bucket?

    Basically my goal is to put my entire website behind CloudFront and minimize the load/traffic on my EC2 web server. If I understand what I’m reading correctly, I can basically route all visitors through CloudFront, allow only CloudFront to access my web server directly (creating a CNAME DNS record that points my domain name to my cloudfront distribution), and keep as much static content as possible in S3. This should provide better security, better performance, more resiliency during unexpected traffic spikes, and potentially lower AWS costs (I can scale down my EC2 server, possibly set up a load balancer). (see https://aws.amazon.com/blogs/startups/how-to-accelerate-your-wordpress-site-with-amazon-cloudfront/)

    Since this is my first attempt at setting up this configuration, would love a good step-by-step on configuring W3 Total Cache for this situation.

    Thank you.

    • This topic was modified 6 years, 3 months ago by Megunticook. Reason: resolved
    • This topic was modified 6 years, 3 months ago by Megunticook. Reason: resolved
    • This topic was modified 6 years, 3 months ago by Megunticook.
    • This topic was modified 6 years, 3 months ago by Megunticook.
Viewing 15 replies - 1 through 15 (of 15 total)
  • Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @megunticook,

    You can find a lot of tutorials online on how to set up AWS with W3 Total Cache. There is a documentation on our FAQ page which you can use, or you can use this tutorial here for example.
    The first thing you need to do in your WP Dashboard is to go to Performance>General settings and enable CDN after which you need to choose CDN Type: Amazon CloudFront.
    I hope this helps

    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @megunticook,

    Was the issue resolved? Please reply to this topic so we can mark it as resolved or assist you further with this issue

    bgdstr

    (@bogdanstratulat)

    As we have not heard from you for a while this forum topic will be marked as resolved. If you have any other questions, please feel free to contact our team, we are always around and happy to assisst you.

    Thread Starter Megunticook

    (@megunticook)

    Thank you for the links: sorry for the delay there. Will be implementing this on my development site soon. Will report back if any issues.

    Thread Starter Megunticook

    (@megunticook)

    I’m just now taking my first crack at setting up W3TotalCache with CloudFront and S3.

    Seem to be stuck though: on the “Configuration:Objects” section of the plugin’s CDN settings, when I click the “Test S3 Upload and Cloudfront Distribution” button, it says: “Error: Distribution for origin “mybucketname.s3.amazonaws.com” not found.”

    I previously set up a CloudFront Distribution with that exact origin (it actually has two origins: the S3 bucket for wp-content/* and wp-includes/*, and also the web server in EC2 for Default(*), wp-login.php, and wp-admin/*).

    I’ve gone over everything again and again but I can’t seem to resolve this. Why would W3TotalCache be saying it can’t find a CloudFront Distribution for that origin? I can plainly see that the CloudFront Distribution has “mybucketname.s3.amazonaws.com” as one of its origins, and the Distribution status says “deployed.”

    Any ideas would be most welcome! Thank you.

    Thread Starter Megunticook

    (@megunticook)

    I finally worked through this issue by letting W3TtotalCache create the S3 bucket and CloudFront distribution, rather than setting those up first then pointing W3TC to them.

    Of course I had to go and configure the distribution after it was automatically generated, but things seem to be working.

    Thread Starter Megunticook

    (@megunticook)

    Getting that “Distribution not found” error again when I hit the “Test S3 Upload & Cloudfront Distribution.” Could this possibly be a W3TC bug? It seems like it’s working fine…when I hit the “upload attachments” button the correct files were copied to S3, and I was able to load pages of the site in my browser and confirm that the images on S3 were being served.

    @megunticook Did you solve this issue? I’m running into this as well.
    Everything seems to be working fine except for the test.
    I have 2 origins, an ALB and a S3 bucket.

    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @megunticook,
    Sorry for the late answer but we had to make some tests to replicate the issue.

    For CloudFront in “Push” category we fully support only the case when distribution has only one s3 origin. Modifications made may keep it functional, but it’s not guaranteed to always work since it depends on how those multiple origins configured and which paths are used by a website.
    Since it is different from case to case we can not guarantee that it will work.

    please clarify, do you mean only one origin or only one s3 origin?

    Most conventional WordPress Cloudfront set-ups have ec2 or elb as origin. Are you saying you need to create a separate distribution for S3 origin?

    Thread Starter Megunticook

    (@megunticook)

    please clarify, do you mean only one origin or only one s3 origin?

    I think he means you can’t use multiple s3 buckets for origins when you’re setting up an origin push with W3T–just one. You could have 1 CloudFront distribution with multiple origins, like for example an EC2 instance and an S3 bucket.

    • This reply was modified 5 years, 5 months ago by Megunticook.

    It doesn’t seem to work if you configure the S3 bucket and EC2 instance or ALB in the same distribution. The S3 seems to have to be in a separate distribution.

    Thread Starter Megunticook

    (@megunticook)

    I’m just setting this up now…but my understanding is that CloudFront can use multiple origins. You see https://aws.amazon.com/blogs/startups/how-to-accelerate-your-wordpress-site-with-amazon-cloudfront/?

    I’ll confirm soon. Need to attend to some other tasks now but will return to getting this set up as time allows and hoping to have it running this week for testing.

    Thread Starter Megunticook

    (@megunticook)

    Update–I’ve deployed and activated my CloudFront CDN and have W3T configured correctly (test button indicated everything OK). I’m now syncing my S3 bucket with the static content on my EC2 instance, and once that’s done I’ll check everything out thoroughly. A quick check on one image did confirm that it’s being served from CloudFront now.

    I’ll report back later with more results. But it certainly seems like CloudFront is working using S3 for static files and EC2 for remainder.

    Once I have that throughly tested, next step is to set up a Load Balancer with Auto-Scaling EC2 instances behind it.

    • This reply was modified 5 years, 5 months ago by Megunticook.
    Thread Starter Megunticook

    (@megunticook)

    One question I have at this point–what happens when, say, a new image is added to the WordPress image library? Is W3T smart enough to immediately upload that image to the S3 bucket? Or does this need to be done manually?

    Also, what about updates to WP and plugins? Again, does W3T automatically push the updated files to S3?

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘setting up origin push with AWS Cloudfront’ is closed to new replies.