1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Nginx rule to stream files behind the home directory?

Discussion in 'Server Configuration and Hosting' started by Cyb3r, Dec 14, 2015.

  1. Cyb3r

    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.
  2. RoldanLT

    RoldanLT Well-Known Member

  3. Cyb3r

    Cyb3r Well-Known Member

    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:

    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
    RoldanLT likes this.

Share This Page