Centos – User uploaded files on different server with PHP

centosPHPphp-fpmSecurityupload

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?

Best Answer

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.