Question

How can i add a second drive to nginx server?

I have a server having two drives each of 2TB. First drive is mounted to “root” (which is called “/”) and the second drive is mounted to /mnt/disk1. I am serving my files from first hard drive at location /usr/share/nginx/html/downloads/ with this default configuration below:

root /usr/share/nginx/html; <---------------default served file location index index.html index.htm; server_name localhost;

location / { try_files $uri $uri/ =404;
}
}

My files can be downloaded at http://ip_address/downloads/softwares/example.exe

Now my first 2TB hard drive is filled and i dont have budget to buy another server. But i have another 2TB of hard drive having all of its 2TBfree space mounted at /mnt/disk1.

Can you please tell me how can i tell nginx to include that 2TB drive so that i can put and serve files from this 2TB drive at location /mnt/disk1

ubuntu nginx web-server ubuntu-14.04


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Only idea I can get is using another location alongside alias directive for second disk. With alias directive you can define replacement location for content.

Look at this example config

root /usr/share/nginx/html;
index index.html index.htm;
server_name localhost;

    location / {
        try_files $uri $uri/ =404;
    }

    location /downloads2 {
        alias /mnt/disk1;
    }
}

With this approach you will have following situation: If you access via http://ip_address/downloads, you will see only content from first disk / If you access via http://ip_address/downloads2, you will see only content from second disk /mtn/disk1.

If you can use multiple locations, e.g. downloads and downloads2, this will get your job done. Problem is if you want to serve files from both disk on one location - /. You will have hard time with this.

thnak you so much… It seams that your idea would work. M just going to to id. ;)

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel