Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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/imageA.png /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?

share|improve this question
1  
If it's a hard link, both files are the real file. There is no way to tell them apart. –  Michael Hampton Dec 19 at 20:36
    
I was afraid of that. :) Thanks Michael. I will edit my question. –  Taytay Dec 19 at 20:38
    
Why do you want to redirect? What problem do you solve? –  Alexey Ten 2 days ago

1 Answer 1

up vote 1 down vote accepted

AFAIK nginx can't do it, but there are other ways possible, like:

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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