Imagine nginx is serving a folder of static images created by rsnapshot: /rsnapshots/hourly.0/imageA.png /rsnapshots/hourly.0/imageB.png
So if I go here:
http://example.com/hourly.0/imageA.png, I see ImageA.png
RSnapshot will just create a hard link if the file hasn't changed since the last backup. So image imageA.png hasn't changed, but B hasn't. So, my recent backup at hourly.0 will now look like this:
/rsnapshots/hourly.0/imageB.png -> /rsnapshots/hourly.1/imageB.png
imageB.png is just a hard link (not a symlink) to /rsnapshots/hourly.1/imageB.png.
So if the client asks for
http://example.com/hourly.0/imageB.png, they'll get
imageB.png, but I could have redirected them to :
http://example.com/hourly.1/imageB.png, and they'd get the same image.
Is it possible for nginx to A) Detect hard links B) redirect the client to the "real" file if it does detect it?
Edit: As Michael astutely observed, there is no "real" file when hardlinks are concerned. They're both just pointers to the same file. In that case, I can think of two modifications to my question: 1) Can Nginx probe other server directories upon a request, test for file existence, and if it finds the file at another path, redirect the client to the other path. 2) If I replaced "hard links" in my question with "symlinks", can I do a test for the symlink, determine where the symlink goes, and then redirect to the symlink path instead?