Getting 5.7 working behind CDN

Permalink 1 user found helpful
Using this howto:http://www.concrete5.org/documentation/how-tos/developers/using-clo... I have tried to configure my c5.7 setup to run behind cloudflare, but am having mixed results. What I ave done so far is just try to configure C5 and apache to use a second hostname that will always bypass the CDN. So what I have is an alias of 'direct.mydomain.com' that points to the c5 root application directory. In config/app.php i have:
if (strpos($_SERVER['HTTP_HOST'],'direct') !== FALSE) {
   define('REDIRECT_TO_BASE_URL', false);
}


and in .htaccess, I have:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^direct\. [NC]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]


Which will not redirect requests to direct.* to www.*

this sort of works, but all images and links to absolute file paths are broken - I don't know if this is due to my config, or something else. Also, the sitemap in dashboard is empty when I try to access it from the direct.mydomain.com url path, even though I can log in ok and see the dashboard

View Replies: View Best Answer
StriderSEO replied on at Permalink Reply
StriderSEO
That's a pretty out-dated guide, so I'm not sure how much it applies to 5.7.

If anyone does figure out how to get C5.7 running with a CDN (ex: MaxCDN!) I would love to know.
nikmartin replied on at Permalink Best Answer Reply
I actually got this working over the weekend. The above config DOES work, but there are several cloudflare specific things to make note of.
1. you can't load many Concrete5 specific javascripts async, so you need to set rocketloader to manual.
2. Anti leeching and anti-hotlinking CDN configs won't work. That's why images weren't working on my direct domain.
3. Adding:
if (strpos($_SERVER['HTTP_HOST'],'direct') !== FALSE) {
        define('REDIRECT_TO_BASE_URL', false);
}
to
/application/config/app.php
does work to prevent getting forwarded to BASE_URL, What doesn't seem to work is the anti-crawler script. That seems to be handled somewhere else now, and adding it had no effect for me, but it's purely optional.
oncledave replied on at Permalink Reply
oncledave
Hi Nik,

I don't really get how this works.
Apart from what you have configured here-above, do you need to set something special at your images ? When I try it, it always gets the images from the base location.
What url do you use to access your server, direct. or www. ? How does it know it needs to get the static content from the direct. url ?

Thanks for your help.

Regards,