Is there any plan for supporting CDN?
The free CDNs : CloudFlare and Incapsula.
The paying CDNs : MaxCDN, CloudFront and CDN77.
Or I just misunderstood about how to setup CDN in CMSes (not limited to ElkArte)?
They work a few stages back at the DNS stage, by default, this software will work with ut.
The only issue that I know of with CDN's is that the $_SERVER['REMOTE_ADDR'] will come in as the IP if the CDN for everyone, so that makes IP tracking / banning / geo location etc mostly unusable ...
CloudFlare sends in the original IP in $SERVER['HTTP_CF_CONNECTING_IP'] (but you should not just use that when found, you need to make sure that the REMOTE_ADDR one is from a CloudFlare range)
Will we support that, or is that addon territory? I'm not sure ... I'm thinking addon as I'd imagine each CDN will have its own IP needs so trying to address that in core would be a source of continual maintenance.
@Trekkie101 and @Spuds : Yeah, that is how CloudFlare and Incapsula do their CDN setup, and I failed badly when trying to use them (not on the same time).
When I'm using MaxCDN there is a difference in how to setup, I don't need to change my NS to them. I just need to add one or more CNAME record to them. I found easier that way.
I agree with you @Spuds this is addon material, because not everyone will use CDN. But I believe for the free ones (CloudFlare and Incapsula) many would request them in the future.
Thanks for hearing me out.
There are more issues with CDN'S if the real IP is not properly passed through the server or CDN:
Session: Users will always get: s"ession expired".
Attachements: Upload due to session problem impossible (same error message)
Search: by Google PSS search is messed up and throws error 414: URL is too long (due to given parameters)
Quick and dirty solution:
add the following to index.php:
$_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_FORWARDED_FOR'];
Search: only solution to set the search to subdomain which is not delivered by CDN.
/me tracks this to remember to check if there is a way to hook and change what is necessary without having to touch the code.
If the various CDN always use the $SERVER variable, we could just add a setting to specify the index holding the IP that we should use.
The only part I'm not sure about, is if having it in $modSettings is early enough to deal with out internals or we need to know the index before that.
It is being tracked for years. Hopefully, this could be resolved / added as features.
Well, my proposal stands only if the condition is valid. Now someone has to verify it. xD
I'm not sure if all of the services send the original IP in the connection.
Doing some more looking, Cloudflare and Incapsula set $_SERVER['HTTP_X_FORWARDED_FOR'] which seems to be the industry standard for these services. So a simple setting to enable CDN may be simply along the lines of.
if (isset($_SERVER['HTTP_X_FORWARDED_FOR']))
{
$_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_FORWARDED_FOR'];
}
That is somewhat unique to CDN's where you change your DNS to point to them and they choose the assets. If you are using, I'll say traditional CDN, such as cloudfront (amazon) then its not a problem since you are simply pointing certain assets (js/css/etc) to be fetched from the CDN URL.
For a traditional setup we would need the ability to point JS, CSS, Theme assests (images), avatars, and maybe attachment URL's, for the borg cloud style CDN simply a check the HTTP_X_FORWARDED_FOR header maybe all that is needed.
Haha... I cannot verify anything regarding this. I don't even know how it is done to to be done properly.
Nothing to verify, my proposal doesn't work because the request cleaning comes before having modSettings populated, so it is too early.
If using CloudFlare ( I do) I just ignore CloudFlare IPs: https://www.cloudflare.com/ips/ and take the needed header: https://support.cloudflare.com/hc/en-us/articles/200170986-How-does-Cloudflare-handle-HTTP-Request-headers-
But if using conventional CDN (pull zone) like KeyCDN/MaxCDN I think Elkarte doesn't support it yet?
Still I do not understand this CDN that much. But as said:
I was thinking if we are to test this cdn idea, we could participate and create a branch of elkarte default static files in there?
Just a thought...
That's correct .. I do have an un-released addon which points asset (JS/CSS/Images/etc) to a CDN of your choice. I use it for Amazon's CDN cloudfront service. Should work with other conventional CDN's as well.
Looks like MaxCDN has been soaked up by StackPath CDN and its, IMO, a bit pricey for what most forums use (looks like min $20 a month?)
I have a free sponsored account from 4 years ago. :P Consuming +- 100GB per month, but only for one domain.
if you want a cheap CDN I can recommend BunnyCDN: https://bunnycdn.com/ for me its the keycdn successor.
Had not seen the rawgit before ... very interesting !
I'll have to hunt around for the CDN code I have, I'm not sure I ever packaged it up for use :-*
I am currently using repair_settings.php to change to a cdn url but currently only avatar, smileys and images folder are covered. So now I am looking for a way to change css and script to use the cdn url as well.
How do I change the settings for these two? Can our repair_settings.php be modified to include both of their url? Or do I need to use an addon?