Good deal
Yeah CF can cause a bit of problems if not set up correctly, but its not too bad, and its easier than many other services that use a different type of CDN with lesser SSL systems. Its worth it in my opinion, especially considering they just pushed http/2 to all sites on their service. This should probably be a seperated post, but examples of things you may run into on CF with OC:
- Turn off Rocket Loader everywhere, its too crufty with OC scripts in various places like checkout.
- Use the standard caching level with an 8 day cache (to pass pagespeed). Then turn off caching with a pagerule to *.yoursite.com/checkout/* (and/or *.yoursite.com/index.php?route=checkout/*)
- If you use HTTPS you need to enforce it everywhere, this will eat 1 pagerule but it fixes APPs not understanding whether or not they have SSL mode on. Be careful with the HSTS settings, read what can happen if you set it up too hardcore and happen to decide not to use SSL anymore (locked out). Be careful setting preload or subdomain flags, better to leave them off unless needed.
- If OC is having troubles understanding what is going on in regards to current SSL mode, you may also need to re-write the $this->server method in system/library/request.php to support more HTTPS headers found in various frontend proxies/balancers/clusters. Example for 1.5.6x series....(this is super secret part of pay mod, might have to remove later

jk). Replace $this->server = $_SERVER; with:
Code: Select all
if (!isset($_SERVER['HTTPS'])) {
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') {
$proxy = array('HTTPS' => 'on');
} elseif (isset($_SERVER['HTTP_X_FORWARDED_PROTOCOL']) && $_SERVER['HTTP_X_FORWARDED_PROTOCOL'] == 'https') {
$proxy = array('HTTPS' => 'on');
} elseif (isset($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') {
$proxy = array('HTTPS' => 'on');
} elseif (isset($_SERVER['HTTP_FRONT_END_HTTPS']) && $_SERVER['HTTP_FRONT_END_HTTPS'] == 'on') {
$proxy = array('HTTPS' => 'on');
} elseif (isset($_SERVER['HTTP_X_URL_SCHEME']) && $_SERVER['HTTP_X_URL_SCHEME'] == 'https') {
$proxy = array('HTTPS' => 'on');
} else {
$proxy = array();
}
$this->server = array_merge($_SERVER, $proxy);
} else {
$this->server = $_SERVER;
}
- Install the CF apache module to re-write visitor IPs correctly....or....use the "CF-Connecting-IP" header to get it at app level (needs re-write). The module works better, but if you are on shared server or something, here is the fix for OC, again found in system/library/request.php. Example, add this before the $this->server stuff in OC 1.5.6x series:
Code: Select all
if (isset($_SERVER['HTTP_CF_PSEUDO_IPV4'])) {
$_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_CF_PSEUDO_IPV4'];
} elseif (isset($_SERVER['HTTP_CF_CONNECTING_IP'])) {
$_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_CF_CONNECTING_IP'];
} elseif (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_FORWARDED_FOR'];
} elseif (isset($_SERVER['HTTP_X_FORWARDED'])) {
$_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_FORWARDED'];
} elseif (isset($_SERVER['HTTP_FORWARDED_FOR'])) {
$_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_FORWARDED_FOR'];
} elseif (isset($_SERVER['HTTP_FORWARDED'])) {
$_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_FORWARDED'];
} elseif (isset($_SERVER['HTTP_X_CLUSTER_CLIENT_IP'])) {
$_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_CLUSTER_CLIENT_IP'];
} elseif (isset($_SERVER['HTTP_CLIENT_IP'])) {
$_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_CLIENT_IP'];
}
- Optimize your orgin server and OC install. It must have fast responses to CF. You have 90 seconds max to establish connection, and if your server is spooling heavy loads, it may not reply with SYN/ACK in time, causing 1 of the 2 types of timeout errors.