Nginx rule to stream files behind the home directory?

Cyb3r

Well-known member
Hey guys. Sometimes I need to download my backup files locally for testing purposes or just to keep them safe. The only way I could do ATM is to move them manually to the public directory which is really dangerous as it might get downloaded by others and/or I accidentally forget to remove them.

So any idea how to set nginx rule like rewrite or something that will allow me to stream files from the backups directory?

Thanks in advance.
 

Yes that did the trick, I have used alias before but I guess I was lazy to try lol

Here my rule for future reference:

Code:
location ~ ^/path/to/my/stream/([^/]+)$ {
    alias /my/backups/directory/$1.tar.gz;
}

Then you can use it like this: www.example.com/path/to/my/stream/anything

The server will try to find this file: /my/backups/directory/anything.tar.gz;

Thank you @RoldanLT
 
  • Like
Reactions: rdn
Top Bottom