Simple CDN service module written in PHP
We used CloudFlare to reduce the traffic load, but as the connection location was LAX (Los Angeles), we found that the speed was very slow, so we urgently created it to use it in the form of a CDN. The server is located in Tokyo (Vultr). The principle is to connect kilho.net/{file} to cdn.kilho.net/{file} to distribute traffic from the main hosting.[PHP] <? $cfg['url'] = 'kilho.net'; $cfg['cache'] = '../data/cache'; $url = $_SERVER['REQUEST_SCHEME'].'://'.$cfg['url'].$_SERVER['REQUEST_URI']; $url_arr = parse_url($url); switch($_SERVER['REQUEST_METHOD']) { case 'GET': $filename = $cfg['cache'].$url_arr['path']; $dirname = dirname($filename); if(!is_file($filename)) { if(!is_dir($dirname)) mkdir($dirname, 0707, true); $ch = curl_init(); $fp =...










