Yes this sound like a pretty simple one to solve from what I understand.
I would first address your haproxy configuration and make a tad more efficient by using ACL's to detect if the requested account is a critical or not critical :-)
You will need to add this to your front end:
acl critical_1 path_beg /~accname1
acl critical_2 path_beg /~accname2
use_backend AppServers_Critcal if critical_1
use_backend AppServers_Critcal if critical_2
default_backend AppServers
Then add these backends.
backend AppServers_Critcal
balance roundrobin
mode http
server TestServer1 12.34.56.78:80 check inter 10s fall 3
server TestServer2 23.45.67.89:80 check backup
backend AppServers
balance roundrobin
mode http
server TestServer1 12.34.56.78:80 check
So a little overview of what is happening here; when the user requests a page it will see if the url begins with a account name that is deemed critical, if so then the user will use the critical server farm which has a backup server specified. However if the account requested is a non critical account it will be sent to the standard server farm.
In addition you may add option forwardfor
in addition to any other options you may have on the backends to ensure the real IP of the client is forwarded to the server. (If you do choose to do this then the server will need mod-rpaf to read the headers sent via the proxy)
(inter 10s fall 3
) You may be wondering what exactly it does; well in short it simply waits 30 seconds and then moves on to the backup.
So it waits ten seconds then check for a consecutive three times before giving up and moving on to the backup server.
(Rsync Guide)
Secondly if you have not already addressed the issue of replicating / synchronizing the server to a remote location via rSync you can follow the steps below to setup a simple automatic system.
First you will need to install rSync & SSH if not already installed. (On both the local & remote server)
(RedHat Based Operating System : Below)
# yum -y install ssh rsync
(Debian Based Operating System : Below)
# sudo apt-get install ssh rsync
Once these packages have been installed you can now create a keyless link between both servers which will allow you to connect without a password from the local machine we are synchronizing to the remote location.
** However please note this is not best practice neither is it the safest however it is one of the simplest methods to achieve full automation. **
(Part 1)
On the local machine you will need to run this command to generate a ssh-keygen file.
# ssh-keygen
This command will then prompt you to answer few questions; this process is pretty straight forward, all you need to do is press the enter key for each question.
(Part 2)
Next we will copy the public key to the remote host using the following command.
ssh-copy-id -i ~/.ssh/id_rsa.pub [email protected] #(Your remote server IP)
It will then prompt you for that server's ssh login password (Using the defined user above; in our case admin-user)
Now were done with that; you will now notice you can ssh to the remote server without it asking for a password, which is what we need to achieve full automated synchronization.
Now we can move back to the rSync.
We can sync the files we need by running this command
rsync -av --delete -e ssh /websites [email protected]:/remote-folder/
and simply we can even add this to crontab in order to make this process run every X days or hours.
A simple example is the one below which will run this command every day at midnight.
00 00 * * * rsync -av --delete -e ssh /websites [email protected]:/remote-folder/
This can be added via typing
crontab -e
I hope this is of help!