Install Fikker Cache to build a self-built CDN to accelerate. Because I have been busy modifying the website theme in the past few days, I quickly share this self-built CDN tool now. After carefully studying the introduction on the official website, I found that Fikker is easy to install and use. It is a good software for building your own CDN. According to the official website, Fikker is a professional-level website cache (Webcache) and reverse proxy server software (Reversed Proxy Server) for CDN/webmasters. The functions that can be implemented include reverse proxy + page caching + Real-time monitoring + traffic statistics + redirection management + HTTPS + CC attack prevention. But after looking at the free version of Fikker, it seems that the page caching function is not available. So the free version can only be used to accelerate CDN for static resources such as images, JS, and CSS. Fikker also has a main control system, which can be used to uniformly manage multiple Fikker cache nodes and form a new CDN cache system. Use Fikker to build your own CDN - supports HTTPS, page caching, real-time monitoring, traffic statistics, and CC attack prevention For more choices about website building software and programs, you can check out:

  1. LNMP: One-click installation script for OneinStack - easily deploy Let’s Encrypt certificate and configure HTTPS site
  2. Use JW Player, ckplayer, Smartideo to build a live video station - supports major video websites and rtmp
  3. Linux VPS website building tool LNMP 1.4 installation and use-SSL automatic configuration renewal and multi-version PHP support
PS: Updated on November 17, 2017, The famous CDN service provider Cloudflare has launched a cooperative distribution plan. You can also join Cloudflare Partner to provide everyone with free CDN services: Join Cloudflare Partner to provide CloudFlare for free CDN acceleration service - no need to modify NS to support SSL.

1. Fikker installation method

Fikker official website: https://www.fikker.com, founded in 2010 by Guangzhou Feike Network Technology Co., Ltd. Installation preparation: Fikker needs to monitor port 80/443/6780. If your server has already installed Nginx/Apache and other services, it needs to be deactivated first. It is recommended to use a new VPS for installation.
#安装wget,若已经安装这一步可省略
yum -y install wget 
#下载安装包
wget -c http://www.fikker.com/dl/fikkerd-3.7.3-linux-x86-64.tar.gz
#解压
tar zxvf fikkerd-3.7.3-linux-x86-64.tar.gz
#进入安装目录
cd fikkerd-3.7.3-linux-x86-64
#运行Fikker
./fikkerd.sh start
Start the installation: Copy the following commands in sequence (requires root user) and execute them. Note: It is suitable for 64-bit versions of operating systems such as CentOS 6.x/7.x. There is no requirement for CPU and more than 4GB of memory. As mentioned above, Fikker listens to port 80/443/6780. Please note that the firewall allows the port and enter the following command:
#如果防火墙使用的iptables(Centos 6)
iptables -I INPUT -p tcp --dport 80 -j ACCEPT
iptables -I INPUT -p tcp --dport 443 -j ACCEPT
iptables -I INPUT -p tcp --dport 6780 -j ACCEPT
service iptables save
service iptables restart
#如果使用的是firewall(CentOS 7)
firewall-cmd --zone=public --add-port=80/tcp --permanent 
firewall-cmd --zone=public --add-port=443/tcp --permanent 
firewall-cmd --zone=public --add-port=6780/tcp --permanent 
firewall-cmd --reload
After completion, visit http://IP:6780. The initial password is 123456. If it cannot be opened, please enter the command netstat -apn|grep ‘6780’ to check whether the port is listening and whether the firewall allows the port. Set the origin site: After adding the host, you also need to set the return-to-origin address to tell the CDN node where to obtain data. After the origin site is added, you are done. You can resolve DNS to the CDN node. (Click to enlarge) Other operations: If you need to register Fikker as a service, please execute the following command:
#注册服务
./fikkerd.sh install
#停止服务
./fikkerd.sh stop
#删除服务
./fikkerd.sh uninstall

3. Self-built CDN system

Step one: First install the Fikker cache (supports Linux/Windows systems). Install Fikker cache on one or more cache node servers for cache acceleration/reverse proxy, etc. Step 2: Then install the Fikker CDN master control. Used to manage multiple cache nodes and synchronize the configuration/domain name traffic statistics/user management/package management of each node. Note: Optional installation item. When there are few nodes, the master control is not required. (Click to enlarge) Step 3: Finally, use third-party intelligent resolution (such as Cloudxns/DNSpod/51DNS/DNSla, etc.). Use third-party intelligent resolution to resolve the domain name of the website to each cache node server IP in a polling/region/line manner. Note: Do not resolve to the main control IP.

4. Summary

Fikker CDN can easily build your own CDN service and supports HTTP/HTTPS, but Fikker occupies 80/443, making it impossible to coexist with your own WEB service. If you don’t want to bother, just use a third-party CDN. After enabling CDN, you will find that the user IP obtained by your program has become the IP of the cache node. To obtain the user's real IP, please refer to the following code to make corresponding adjustments.
#php 获得用户真实 IP 代码举例:
function getRemoteIP()
{
    if (!isset($_SERVER["HTTP_X_FORWARDED_FOR"])) /* 存在 X-Forwarded-For 吗? */ 
    {
        return $_SERVER["REMOTE_ADDR"]; /* 兼容已有程序 */
    }
    
    return $_SERVER["HTTP_X_FORWARDED_FOR"]; /* 返回用户真实 IP, 如为多个 IP 时, 则取第一个 */
}

#asp.net 获得用户真实 IP 代码举例:
void getRemoteIP() 
{ 
    string SourceIP = Request.ServerVariables["HTTP_X_FORWARDED_FOR"]; /* 存在 X-Forwarded-For 吗? */
    if (string.IsNullOrEmpty(SourceIP)) 
    {
        SourceIP = Request.ServerVariables["REMOTE_ADDR"]; /* 兼容已有程序 */
    }
    
    Response.Write(SourceIP); /* 返回用户真实 IP, 如为多个 IP 时, 则取第一个 */
}

#asp 获得用户真实 IP 代码举例:
 0 Then 
strIPAddr = Request.ServerVariables("REMOTE_ADDR") 
ElseIf InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), ",") > 0 Then 
strIPAddr = Mid(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), 1, InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), ",")-1) 
ElseIf InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), ";") > 0 Then 
strIPAddr = Mid(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), 1, InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), ";")-1) 
Else 
strIPAddr = Request.ServerVariables("HTTP_X_FORWARDED_FOR") 
End If 
getIP = Trim(Mid(strIPAddr, 1, 30)) 
End Function

ip=getRemoteIP()
response.write(ip)
%>

Leave a Reply