1. Home
  2. vDDoS Proxy Protection
  3. Configuration
  4. Add Website Caching

Add Website Caching

So you have successfully added a site (your-domain.com) to vDDoS, if you want to enable the cache function for this site as a CDN Server in vDDoS, you need to reconfigure the Cache, changing from no to yes.

Enable Cache:

1. Edit website.conf:

nano /vddos/conf.d/website.conf

# Website       Listen            Backend               Cache  Security  SSL-Prikey  SSL-CRTkey
your-domain.com	http://0.0.0.0:80 http://20.79.197.2:80 yes     no       no          no

In that configuration:
Website is: your-domain.com

http://0.0.0.0:80 is: Protocol & IP:PORT, that vDDoS needs to listen to serve for your-domain.com domain.
http://20.79.197.2:80 is: Protocol & IP:PORT of the original web server of your-domain.com, which you want vDDoS to know and transfer traffic to that server (it’s called a Backend Server)

Cache is: yes
Security is: no
SSL KEYs is: no & no

2. Restart vDDoS (After each configuration change):

[root@vDDoS ~]# vddos restart

(Defensive Estimating ~ 273 RealReq/s)
0.0.0.0:80
vDDos service Restart success!


Check:

[root@vDDoS ~]# ls -lah /var/cache/vddos

total 24K
drwx------ 6 vddos root 4.0K May 30 06:00 .
drwxr-xr-x 8 root  root 4.0K May 30 00:35 ..
drwx------ 2 vddos root 4.0K May 30 00:35 client_temp
drwx------ 2 vddos root 4.0K May 30 00:35 temp
drwx------ 2 vddos root 4.0K May 30 06:00 your-domain.com-cache-9648661874
drwx------ 2 vddos root 4.0K May 30 06:00 your-domain.com-temp-9648661874

[root@vDDoS vddos]# curl -I http://your-domain.com

HTTP/1.1 200 OK
Server: nginx-V-ddos
Date: Tue, 30 May 2017 10:06:47 GMT
Content-Type: text/html
Content-Length: 51102
Connection: keep-alive
Keep-Alive: timeout=15
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Set-Cookie: PHPSESSID=94489640436ae9ecde685d3a7411267e; path=/
X-Powered-By: ASP.NET
X-Powered-By-Plesk: PleskWin
X-Proxy-Cache: MISS




Enable Static Cache:

1. Create your-domain.com.server.conf or your-domain.com.location.conf:

nano /vddos/conf.d/cus/your-domain.com.server.conf

location ~* .(gif|jpg|jpeg|png|wmv|avi|mpg|mpeg|mp4|htm|html|js|css|mp3|swf|ico|flv)$ {
    expires max;
    proxy_set_header  X-Real-IP  $remote_addr;
    proxy_pass http://20.79.197.2:80;
    proxy_ignore_headers X-Accel-Expires Expires Cache-Control;
    proxy_store /var/cache/vddos/static-$host$request_uri;
    proxy_store_access user:rw group:rw all:r;
}

In that configuration:
http://20.79.197.2:80 is your backend server
/var/cache/vddos/static- is your static file cache directory

2. Restart vDDoS (After each configuration change):

[root@vDDoS ~]# vddos restart

(Defensive Estimating ~ 273 RealReq/s)
0.0.0.0:80
vDDos service Restart success!


Check:

[root@vDDoS ~]# du -sh /var/cache/vddos/*

4.0K    /var/cache/vddos/client_temp
4.0K    /var/cache/vddos/your-domain.com-cache-4682359681
332K    /var/cache/vddos/your-domain.com-cache-8362946601
4.0K    /var/cache/vddos/your-domain.com-temp-4682359681
4.0K    /var/cache/vddos/your-domain.com-temp-8362946601
199.4M  /var/cache/vddos/static-your-domain.com
4.0K    /var/cache/vddos/temp

/var/cache/vddos/static-your-domain.com is your static file cache directory

When querying static files listed in the configuration (gif|jpg|jpeg|png|wmv|...), vDDoS will keep those static files in the directory ./static-your-domain.com and serve on the next time.
Please delete ./static-your-domain.com periodically if it is too large or too old:

[root@vDDoS ~]# rm -rf /var/cache/vddos/static-your-domain.com

Was this article helpful to you? Yes No