Apply all necessary steps from R Consulting Appliances Installation, Initial configuration checklist first.
Initialize cache volume, add to /etc/rc.conf.d/datamount
:
datamount_enable="YES"
datamount_vol1="gpt/vol1"
datamount_wwwcache="vol1"
Cache configuration in /usr/local/etc/nginx/local.hac-cache.conf
:
# Fields to customize: cache size of 10M fits about 75k URLs,
# inactive depends on site configuration, max_size on free space
proxy_cache_path /srv/wwwcache
levels=1:2 keys_zone=upstream.cache:32M
inactive=48h max_size=320G
use_temp_path=off;
Change inactive
and max_size
and refer to nginx documentation if must.
Configure upstream in /usr/local/etc/nginx/local.http.upstreams.conf
:
upstream us1 {
server upstream:80;
keepalive 4;
}
us1
is upstream id, as referenced in the upstreams.lua
script (see below). upstream
is the host name of source server. It could be simply left as upstream
, as long as respective alias is added to /etc/hosts
. One file can list several upstreams.
Create /etc/rcons/hac/upstreams.lua
:
return {
["1.2.3.4"] = "us1", -- <-- storage IP
["1.2.3.5"] = "us1", -- <-- my IP
["acme.com"] = "us1" -- <-- my host name (for SSL)
};
(Optionally) enable CORS, required for HLS playback on some devices; create /usr/local/etc/nginx/local.conf.cors.conf
:
map $http_origin $cors_origin {
default "";
"~^https?://tv.acme.com(:[0-9]+)?$" "$http_origin";
}
and replace tv.acme.com
with mobile TV service address’ domain.
Add to /usr/local/etc/nginx/local.http.upstreams.conf
on the edge HAC:
upstream us1 {
server upstream:80;
keepalive 4;
}
where us1
and upstream
have same meaning as when no cascading is in use, however us1
is passed as Host:
HTTP request header when edge is addressing the caching HAC.
Add to /usr/local/etc/nginx/local.http.revproxy.conf
on the caching HAC:
server {
listen 80;
server_name us1;
allow 192.168.0.0/16;
deny all;
location / {
proxy_http_version 1.1;
proxy_pass http://us2;
proxy_cache upstream.cache;
proxy_cache_valid 200 24h;
proxy_set_header User-Agent nginx/$nginx_version;
proxy_set_header RcHlsCdn-Accel-Id $hostname;
proxy_set_header RcHlsCdn-Accel-Host $http_rchlscdn_accel_host;
proxy_set_header RcHlsCdn-Accel-Peer $http_rchlscdn_accel_peer;
proxy_set_header RcHlsCdn-Accel-UA $http_rchlscdn_accel_ua;
proxy_set_header Connection "";
}
}
where (server name) us1
is the upstream id under which edge HAC references caching HAC in the previous point, and us2
is the upstream id for caching HAC’s upstream. 192.168.0.0/16
is IP subnet edge HACs will accessing caching HAC from.