How to pre-import files from Rsync daemon - Video CDN

How to pre-import files from Rsync daemon - Video CDN

How to pre-import files from Rsync daemon - Video CDN [EN]

This guide relates to Rsync.

Preparations

Before you begin, ensure you have access to a Linux server with root privileges.

This guide assumes the server is running Ubuntu 24.04. If you’re using a different distribution, adjust the steps accordingly.

For the purposes of this example, our vCDN Resource ID will be vcdn10000000.

Install the daemon

We’ll use the system user foo with the home directory /home/foo:

# connect to the server ssh foo@origin-1.example.com # install rsync daemon sudo apt-get update sudo apt-get install rsync

Once installed, we can configure the daemon:

# make a folder for content mkdir /home/foo/content # configure daemon sudo echo > /etc/rsyncd.conf <<EOF lock file = /var/run/rsync.lock log file = /var/log/rsyncd.log pid file = /var/run/rsyncd.pid [content] path = /home/foo/content comment = sample video content uid = foo gid = foo read only = yes list = yes auth users = vcdn secrets file = /etc/rsyncd.secrets EOF

Here, we define the [content] module, make it read-only, and require authentication using the vcdn user. Next, we create the authentication file /etc/rsyncd.secrets:

# configure authentication secrets sudo echo > /etc/rsyncd.secrets <<EOF vcdn:axT882LasxoA EOF # set secure permissions sudo chmod 600 /etc/rsyncd.secrets

Now restart the daemon and verify it’s running:

# we're ready, restart the service sudo systemctl restart rsync # check if the port is open sudo netstat -atnp | grep rsync # output will be like this: # tcp 0 0 0.0.0.0:873 0.0.0.0:* LISTEN 1911/rsync # tcp6 0 0 :::873 :::* LISTEN 1911/rsync # let’s add a sample file to test the setup: cd /home/foo/content wget http://example.com/sample1.mp4

Finally, confirm you can list files over rsync from the local host:

rsync -avzn rsync://vcdn@origin-1.example.com:873/content/ ./content/ # enter the password: axT882LasxoA # output will be like this: # Transfer starting: 2 files # ./ # sample1.mp4 # # sent 28 bytes received 105 bytes 1330000 bytes/sec # total size is 1570024 speedup is 11804,60

At this point, the origin server is ready.

Configuring files import from origin

  1. Go to Resources.

  2. Select the required resource

  3. Then open the File Import tab and click Add new source:

5c006d31-04d8-4593-9692-8d41c5fed852.jpg

 

In the dialog that appears:

81e90c81-79b9-4881-a0bd-4fbf08804e23.jpg

 

  1. Enter the rsync URL in the format:

rsync://<user>:<password>@<hostname>:<port>/<module>/.

For example:

rsync://vcdn:axT882LasxoA@origin-1.example.com:873/content/
  1. Click Add new source to save the configuration.

dd851581-0348-4431-b277-c70dd7fb4aee.jpg

 

The CDN is starting importing files from the origin. This process can take several minutes: up to about 5 minutes for small and medium-sized files.

Check the result

You can watch on the rsync daemon log to see the import progress:

tail -f /var/log/rsync.log

Once the import is complete, the status will change to Active:

d53672de-db43-47bb-ae9e-6e78df091c52.jpg

 

You can now fetch files via the CDN using your own domain or the system domain:

curl -vL http://vcdn10000000.blazingcdn2.net/sample1.mp4