Putting a cloudfront CDN in front of trellis machine

Been struggling with this one for a few days. We have been attempting to use a CDN, that points to a ec2 that is hosting a remote Trellis configuration. Handling the redirection has been circular thus far, and I haven’t been able to find any search hits on anyone else’s lived experience through a similar setup. Anyone been through this, or have some tips? I’m about to post in the roots discourse site as well. Ultimately, what we are trying to accomplish is that CDN xxx.yyyy.zzz caches wordpress at ec2 address xxx.yyy.origin.zzz. I know that we can use caching within treillis, but we want to take advantage of all the other perks of a CDN. Thanks!

Yeah I am doing this. Let me know exactly you are having trouble with.

I’m about to post in the roots discourse site as well.

But you are in the roots discourse haha!

1 Like

Ack I copy/pasta’d my reddit post. Blew it!

The CDN url keeps redirecting back to the origin url (ec2). I can’t seem to find a configuration in the wordpress_sites.yml (currently just testing for stage) to make it stick with the CDN url throughout the whole site.

In your .env file, are WP_HOME and WP_SITEURL set as the CDN or EC2 URL?

I specify a env section in the staging/wordpress_sites.yml file, where I assign wp_siteurl to the /wp and the wp_home to the . ‘canonical’ is set to the ec2 url as well, and ‘redirects’ points to the cdn. SSL is enabled, cache is assigned false. I’ve tried switching these things around, but I’m certainly missing something, especially with the aforementioned configurations.

Sorry I missed this, try setting canonical to the CDN url, and remove redirects.

This topic was automatically closed after 42 days. New replies are no longer allowed.