I want to host a social type of site. It will be on node (or vertx) . My question is........ if I have a separate image server on my Local area network.. when a user uploads a file should the file be saved to the image -nginx server and then the database told about it and given a link for the picture?
for instance it would be like this:
db.users.find('profilepicture' : 1)
profilepicture: localaddressoftheneginxserver/imagefolder/imagename.jpg
Am I thinking things through correctly? Have the image served on a separate nginx server... have the database not include the actual picture but a link to the picture... so when a client connects to the app server and asks for a particular picture it queries the database, the database sends the link to the app server... and then the app server informs the users computer of the pictures location?
would that work? i'm just a little confused about how someone on the outside could connect to an app server and then also be able to connect to an image server on the same local area network even if they had the address. Would the image server need to be some separate IP?
We had a similar use case and the way we handled it was the following:
That way, the HTTP client only ever communicates with the application server which retains all the business logic / security / access control / etc. It only reads from the image server.
Actually letting a user directly write to the image server could be a security risk because this type of server typically doesn't have much control on what is uploaded (unlike the application server).