Serving HTTPS with Cloudfront but backing HTTP orgin

Viewed 397

I have a Wordpress server running on EC2 and currently it's only running HTTP and I'd rather avoid the hassle of setting up SSL on it. What I'm hoping is that I can co-opt Cloudfront to serve all requests to clients using HTTPS (using an AWS Certificate Managed SSL cert) and then refresh it's cache with HTTP calls to the origin server. This type of configuration is quite straight forward with Cloudflare but it's more of a reverse-proxy than a traditional CDN. Is this a reasonable architecture for Cloudfront?

I had originally thought that the "Behavior" for Viewer Protocol Policy could be set to "Redirect HTTP to HTTPS" but at least initially I appear to be getting the page to load over HTTPS but all assets on the page fail to load because they're still pointed to HTTP. Possibly this a different issue but I'm having an issue grokking it all.

Just for reference, here's my Behaviors dashboard:

enter image description here

And my origin:

enter image description here

2 Answers

You can do it via Origin Protocol Policy option in AWS Console. Select HTTP Only.

To do this select your Cloudfront configuration > choose Origins and Origin Groups tab > Choose your origin > Click Edit button

enter image description here

Remember that you are doing changes for Origin. You have to keep Viewer Protocol Policy to Redirect HTTP to HTTPS as indicated in the question so that traffic between browser and Cloudfront remains HTTPS whereas Cloudfront connects to your Origin via HTTP

Edit: Question description does show that origin is set to HTTP Only which should be enough to do it. Double check if your distribution is in Deployed state.

After setting up CloudFront to deal with HTTPS, you also need to configure WordPress so it generates all the links and asset sources with HTTPS. You can follow the documentation for that.

In short:

  1. Go to Settings -> General
  2. Change http:// to https:// in WordPress Address (URL) and Site Address (URL).

enter image description here

Related