Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

If I had a dozen "Work" servers with just PHP-FPM (with other Nginx servers in front), is it possible to setup PHP to store user uploaded files on a different server?

I'm looking to avoid syncing user files on each "Work" server. I want to keep user uploaded files on an isolated server. With files that need to be accessible to the public, they could be distributed through a CDN.

I have several reasons for wanting to do this:

1) The sum file-size of all the uploaded files are several GB. 99% of them are jpg/png/pdf, but there are thousands of them. If I add another "Work" server, I'd rather not sync those files to another server. These "Work" servers should only contain the application code and do the work.

2) From a security standpoint, I don't want user uploaded files on these servers.

So I basically want to avoid writing these files on the hard drives of the "Work" servers.

What options do I have, if any?

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

From your storage server, export an NFS share to your "Work" servers, then mount to whatever location on the work servers you need. As long as you make sure that filenames and directories are unique, you can have several servers writing to the same NFS export at the same time.

share|improve this answer
    
This seems like a good idea. Is there a way to make it impossible to execute files on this mounted share? Perhaps mounting options that forbid this kind of activity? –  Luke Sep 25 '11 at 18:52
1  
Sure, you can mount it noexec just like any other filesystem mount –  EEAA Sep 25 '11 at 18:53
    
Awesome! Just what I was looking for. –  Luke Sep 25 '11 at 18:59
add comment

Absolutely. My company puts image/video uploads directly onto Amazon S3 using their HTTP POST interface. Works well.

share|improve this answer
    
I'm not entirely clear what you mean. Many of our forms contain text fields and file upload fields. The text fields need to go to the "Work" server and the files need to be stored on the "Storage" server. This needs to happen in a single POST request (which is routed through the "Web" servers to the "Work" servers). –  Luke Sep 25 '11 at 18:53
    
That's fine. Have your web server pass the file on to S3. We pass them directly to S3 from the form (using a SWFUpload widget) as it removes the middleman. –  ceejayoz Sep 25 '11 at 19:17
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.