External File Storage

Hi there everyone, this might seem like a noob question but…

I’ve got 2 servers: a web hosting server, and a database/storage
server.

I want to be able to manipulate the files on the storage server
through my rails app (read/write etc) but they need to be secure so
they can’t just be in a publicly accessible folder (access determined
by the rails app). I don’t have much control of the servers
themselves, so I don’t think I can just hook up a private LAN… it
has to be done through the net.

What’s the easiest way to do this? I’ve never really had to consider
it before…

Thanks!
Jonathan.

Jonzo wrote:

Hi there everyone, this might seem like a noob question but…

I’ve got 2 servers: a web hosting server, and a database/storage
server.

I want to be able to manipulate the files on the storage server
through my rails app (read/write etc) but they need to be secure so
they can’t just be in a publicly accessible folder (access determined
by the rails app). I don’t have much control of the servers
themselves, so I don’t think I can just hook up a private LAN… it
has to be done through the net.

What’s the easiest way to do this? I’ve never really had to consider
it before…

Thanks!
Jonathan.

If the storage server has an SSH server, you could use Net::SSH.

http://net-ssh.rubyforge.org/

Thanks :slight_smile: i’ll take a look

On Jan 10, 3:39 pm, Jeremy Weiskotten <rails-mailing-l…@andreas-

Hi I had a look at that, and to be honest, I’m not too familiar with
how to share files over ssh… sftp maybe…

Maybe I’m a bit delusional, but I’m thinking this must be a more
common problem with a more documented solution surely?

I’ve seen people talking about hosting rails on multiple ec2 instances
a lot, how do people share uploaded images between web-server
instances? am I missing something?

Jonathan.

Hi,

There isn’t a magic ‘share files’ button to find. You need some way to
do it, as Jeremy mentioned one way to do it is with ssh between the
servers.

From what you say, (accessing uploaded images?) what you want is a
network file system, like for example NFS (there are dozens of
different ones all with pros and cons - like NFS traditionally causes
big problems when trying to write to the same file from multiple
places since it’s locking isn’t too good, though is always getting
better).

That way, you can set up the filesystem from the ‘server’ machine
which can be mounted by the ‘client’. So accessing shared files is
essentially going to a specific directory on the client (where the
file system is mounted).

Then you need to look at other things, like if you don’t have a
private/internal network then you need some iptables rules to only
allow your client to talk to the network filesystem (to stop nasty
people doing naughty things to it :).

Probably some network filesystem research will get you where you want to
go.

Good luck, HTH.

Malcolm.

Thanks for that! I think you’re completely right about the network
file system. I’ve read about them before but I didn’t think of it at
all. Thanks heaps everyone!

Jonzo wrote:

Hi I had a look at that, and to be honest, I’m not too familiar with
how to share files over ssh… sftp maybe…

Maybe I’m a bit delusional, but I’m thinking this must be a more
common problem with a more documented solution surely?

I’ve seen people talking about hosting rails on multiple ec2 instances
a lot, how do people share uploaded images between web-server
instances? am I missing something?

Jonathan.

Well, you could use S3. Maybe that’s what you’re talking about. EC2 is a
compute cloud. S3 is the Amazon Simple Storage Service. You could use
that – I think it’s secure. There is a Ruby API for it.

Another possibility could be to setup a VPN I guess, what’s the
general opinion out there about this option?