E
E
Eugene0072014-03-15 20:52:01
Apache HTTP Server
Eugene007, 2014-03-15 20:52:01

How to do realtime rsync if file not found on current server?

I would like to set up a server for developing a site with an up-to-date database that is in production, but at the same time not to synchronize all the files that are stored on disk, but to do it on the fly, as needed.
There is a production server that hosts a website with ~40Gb of content files (pictures, documents, videos, etc.).
There is a development server that wants the following:
- if the Apache server cannot find a file in a certain directory and wants to return 404 => you need to rsync and try to find the file again
- if php tries to work with a non-existent file (for example, find out its size to display information on the page) => do rsync(in my opinion, it's complicated, but it would be ideal)
Ways of solution that I imagine:
- do it at the file system level (ideal, but I don't know how :)
- special Apache module or configuration that handles 404 error and does rsync
- cron, which parses error.log for 404 and does rsync (simple, but there is a time delay)
- Varnish configuration, which allows rsync on 404
Maybe someone has a ready solution, or suggestions.
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vlad Zhivotnev, 2014-03-15
@inkvizitor68sl

Nginx can do this (not rsync, but give the file to the user from another server and save the file locally).

location / {
    root /var/www/cache;
error_page 404 = @storage; 
 }

  location @storage {
    proxy_pass http://2ndserver;
    proxy_store on;
    proxy_store_access user:rw  group:rw  all:r;
    proxy_temp_path /var/www/cachetmp
    root /var/www/cache;
    access_log off;
  }

I'm not sure that I wrote the whole syntax correctly from memory, but the main idea should be clear.
And sometimes do rsync on the crown.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question