I have Wordpress installation running on two web servers (Nginx). There is unidirectional synchronization from server A to server B and I'm using lsyncd for this purpose.

  • with his configuration I have to add blog posts from the first web server so the data is replicated to the second one - how I can force access to Wordpress back-end only from the first web server?

Please note that both servers have the same domain for Wordpress.


  • Is there a load balancer in front of the two servers, or are they contactable directly? – EightBitTony Jun 25 '12 at 9:51
  • Unfortunately only RRDNS – HTF Jun 25 '12 at 10:05
  • have you got 2 separate DB's on both boxes? – Rhys Evans Jun 25 '12 at 12:30
  • I've got Master/Slave configuration on separate servers – HTF Jun 25 '12 at 14:38

how I can force access to Wordpress back-end only from the first web server?

It could be achieved with a two-step process...

Step 1:

On your second web server, please add the following blocks just before location / block...

location /wp-login.php {
  return 301 $scheme://ip.of.1st.server$request_uri;

location /wp-admin {
  return 301 $scheme://ip.of.1st.server$request_uri;

Step 2:

On your first web server, please add the following vhost configuration...

server {
    server_name ip.of.1st.server;
    return 301 $scheme://domainname.com$request_uri;
  • Sign the backend link with backend-d9c4efd247b4cf75ad6c0fc5-xx.xx.xx.xx.dns-x.wordpress.com and use it against commercial and government intelligence. – Andrew Smith Jun 26 '12 at 0:30

Assuming you are using a L7 load balancer, you could just redirect based on URI. If you are using RRDNS - then you don't really have much control.

But you could just use a shared file-system like NFS, then it wouldn't matter which machine was running the admin - as it would essentially be bidirectional.

  • There is only RRDNS. Unfortunately I have to stick to the current setup for now (two separate web nodes without shared storage) so is there any better solution for data replication than "lsyncd" that is bidirectional? – HTF Jun 25 '12 at 10:09
  • 1
    If the replication needs to be in real-time, lsyncd is the next best approach (other than NFS/Gluster). If it can be slightly delayed, the rysnc on a cron would would and could operate from each machine. What's the point in 2 servers using RRDNS - you don't have proper load balancing or any proper redundancy? – Ben Lessani - Sonassi Jun 25 '12 at 10:11
  • I'm using dyndns traffic management but I'm planning to use Red Hat Load balancer in the future. I think shared storage would be the best option. – HTF Jun 25 '12 at 10:21

Can you exclude files from replicating with lsyncd? You could just remove some of the files from /wp-admin/ on the 2nd host so you can't use that host to create posts, like admin.php.

Note: Untested.

  • WordPress can be access it only with one domain so there won't be a way to redirect clients to the admin back-end on the first node. – HTF Jun 25 '12 at 10:00

You could use domain like backend-d9c4efd247b4cf75ad6c0fc5-xx.xx.xx.xx.dns-x.wordpress.com and you would have to use different database schema and eventually sql replication between users too. You can even do more security and copy sensitive banking data only to your backend and not the frontend.

  • My initial idea was to create rewrite rule on the web servers as follow: example.com/wp-admin to admin.example.com on both web servers (with admin.example.com pointing to the first one) - however the problem is that WordPress can be access it only with the main domain (example.com) and there's no way to login to the WordPress admin on each server, since they're set by domain from the database. – HTF Jun 25 '12 at 9:56
  • 1
    What about slightly patching the code, so it works from both? This would be the best solution from security view, so when you access backend, you dont access the same account as on the frotend. This way, you can secure filesystem on the frontend. – Andrew Smith Jun 25 '12 at 11:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.