Synchronise Files on Pexip Reverse Proxy

If you have deployed more than one reverse proxy, there may be scenarios where it might be useful to replicate files from one to another in an automated fashion. For instance, if you are providing custom branding as described in this article: Pexip Reverse Proxy – Hosting unique branding for multiple domains then you will want to keep the same branding files and directories on both instances.

In this article, you’ll see how to synchronise the contents of the /var/www/branded folder across two reverse proxy instances. This will allow you to copy new branding subdirectories to RP1 and have them automatically copy themselves to RP2 so that they are immediately available.


For this example, RP1 will be the reverse proxy instance that will host the files and directories located in the /var/www/branded folder and uses lsyncd to mirror these contents to the second reverse proxy instance, RP2.

SSH into RP1 and run:

sudo apt-get update
sudo apt-get install lsyncd
sudo mkdir /etc/lsyncd

Now create a new config file:

 sudo nano /etc/lsyncd/lsyncd.conf.lua

Add the following. Change the IP address of the targetlist to the IP address of RP2:

settings {
   logfile = "/var/log/lsyncd/lsyncd.log",
   statusFile = "/var/log/lsyncd/lsyncd-status.log",
   statusInterval = 20
targetlist = {


for _, server in ipairs(targetlist) do
  sync{ default.rsync,
    delete = false,
    rsync = {
        compress = true,
        acls = true,
        verbose = true,
        rsh = "/usr/bin/ssh -p 22 -o StrictHostKeyChecking=no"

Note: If you want to sync to more than one RP, simply configure the targetlist with more targets. Example:

targetlist = {

If you don’t already have the /var/www/branded folder created on RP1 and RP2, create it using the below command:

sudo mkdir -p /var/www/branded

Now we want to allow the root user on RP1 to login to RP2. Press enter to accept defaults:

sudo su
ssh-keygen -t rsa
scp /root/.ssh/ pexip@

(where should be replaced with the IP of your RP2)

On RP2:

sudo su
ssh-keygen -t rsa
cat ~/ >> /root/.ssh/authorized_keys

Test from RP1:

ssh root@

(where should be replaced with the IP of your RP2)
You should be allowed to SSH into RP2 without being prompted for a password.

Now we want to prepare the OS for logging:

sudo mkdir /var/log/lsyncd
sudo touch /var/log/lsyncd/lsyncd.{log,status}

Now start the service:

sudo service lsyncd start

Test that it works by creating some files in the /var/www/branded/ folder on RP1 and make sure that the files then appear on RP2:

sudo touch file{1..10}


ls /var/www/branded/

You should see 10 new files on RP2:

file1 file10 file2 file3 file4 file5 file6 file7 file8 file9

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s