You are right with your configuration if you want to use http://droplet-ip/databank/
.
In your nginx server block you already added:
location /databank/ {
alias /mnt/volume-fra1-01/databank/;
}
So that’s all. Make sure you restarted nginx after that. You can also test nginx configuration with:
It should ouput something in line of this:
Sample output of sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
If this is OK, restart nginx:
- sudo systemctl restart nginx
Now there some important point:
Accessing http://droplet-ip/databank
will return 404 Not Found!
Accessing via http://droplet-ip/databank/
(note the red slash) will work.
To fix that remove last /
in location /databank/
. You will have now:
location /databank {
alias /mnt/volume-fra1-01/databank/;
}
Restart nginx again and when you go to http://droplet-ip/databank
it will return now 403 Forbidden.
This is because you didn’t specified file to open. Go to /mnt/volume-fra-01/databank/
and create some html file (e.g. file called abc.html
).
Write some html code in it:
nano abc.html
<html>
<head>
<title>Hello World!</title>
</head>
<body>
<p>Hello World!</p>
</body>
</html>
Save it and exit.
Now go to http://droplet-ip/databank/abc.html
from your browser and you should see Hello World!
paragraph.
If for some reason when you go to http://droplet-ip/databank
you want to list all files, you can add autoindex on
under nginx location block. This will show you all files you have in databank
when you access http://droplet-ip/databank
.
For that your location block should look like this:
location /databank/ {
alias /mnt/volume-fra1-01/databank/;
autoindex on;
}
Restart your nginx once again, go to http://droplet-ip/databank/abc.html
and you should see all files from databank
directory on disk.
Note that this is not something so recommended. Keep in mind that anybody will be able to see all your files in /mnt/volume-fra1-01/databank/
.
If this is what you want, good luck, I hope it works for you :)
As per?
Wait a second. Do you want to when you or someone else type
http://droplet-ip/home/mrneilypops/databank/
in browser it serves content from volume?Or you want when you go to
/home/mrneilypops/databank/
in your console, SSH, it shows you content of it?If you want second, this tutorial will not work, as it works only if you want to serve it on Web, via nginx.
I would like to access /home/mrneilypops/databank/ and show content of /mnt/volume-fra1-01/databank/
I am running Ghost blog on my site so I don’t know how I would access something like;
http://droplet-ip/home/mrneilypops/databank/ in a browser…this would be the ideal solution.
Any suggestions welcome.