Problems using custom CNAME with CloudFront CDN over SSL
-
I have a problem configuring W3TC when using a custom CNAME and SSL/HTTPS for a CloudFront distribution.
I set up a CloudFront distribution to use as a CDN on my WordPress site, using the W3TC plugin to configure things. I imported an SSL certificate to use with the CloudFront distribution. I used a CNAME for the distribution (e.g., “cdn.example.com”) to use in place of the CloudFront domain name (e.g., “d1234.cloudfront.net”).
I set up W3TC, enabling the CDN as Amazon CloudFront in the General settings. In the W3TC CDN tab settings, I enabled SSL support and entered the custom CNAME. The “Test CloudFront distribution” button indicated the green “Test passed”.
All seemed OK until I checked the site front-end and saw that all the images were just broken image links. Right-clicking an image to open it in a new browser window resulted in the browser warning me that “the connection is not private” and that the website “may be impersonating cdn.example.com”. A glance at the source showed that none of the CloudFront CDN resources were being loaded.
Clearly there was something wrong and it seemed as if the CloudFront distribution wasn’t associating itself correctly with the SSL/HTTPS connection.
However, after experimenting I found that if I deleted the CNAME (i.e., “cdn.example.com”) in W3TC, and used the not-so-pretty CloudFront domain name (i.e., “d1234.cloudfront.net”) instead, everything worked all right. Images loaded successfully from d1234.cloudfront.net, where they wouldn’t from cdn.example.com.
I have another site that is set up exactly the same except it doesn’t use SSL/HTTPS: the use of a custom CNAME for the CloudFront distribution there doesn’t cause any problems at all.
Therefore the problem seems specifically to occur when using a custom CNAME and SSL/HTTPS with a CloudFront CDN.
I realise that this problem straddles different technologies and platforms, any of which might be implicated, but since W3TC is intimately associated with setups like this, I wondered if anyone might know why I have these problems when I configure W3TC using the CNAME, with a CloudFront CDN used with SSL/HTTPS.
- The topic ‘Problems using custom CNAME with CloudFront CDN over SSL’ is closed to new replies.