简体   繁体   English

使用NGinx作为图像服务器,将mongodb作为数据库,将节点作为应用程序服务器…?

[英]Using NGinx as an image server with mongodb as a DB and node as app server…?

I want to host a social type of site. 我想托管一个社交类型的网站。 It will be on node (or vertx) . 它将在节点(或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? 我的问题是........如果我的局域网上有一个单独的图像服务器..当用户上传文件时,应将文件保存到图像-nginx服务器,然后数据库告知它和给图片的链接?

for instance it would be like this: 例如,它将是这样的:

db.users.find('profilepicture' : 1) db.users.find('profilepicture':1)

profilepicture: localaddressoftheneginxserver/imagefolder/imagename.jpg 资料图片:neginxserver / 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? 将图片放在单独的Nginx服务器上...让数据库不包含实际图片而是图片的链接...因此,当客户端连接到应用服务器并要求提供特定图片时,它将查询数据库,数据库将链接发送到应用服务器...,然后应用服务器通知用户计算机图片位置?

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? 图像服务器需要使用一些单独的IP吗?

We had a similar use case and the way we handled it was the following: 我们有一个类似的用例,处理方式如下:

  • The image is uploaded to the application server first, where it is stored as a temporary file. 图像首先上载到应用程序服务器,并在其中存储为临时文件。
  • (optional) Run some validation on the image format, resize it if needed. (可选)对图像格式进行一些验证,并根据需要调整其大小。
  • Transfer / deploy the image from the application server to the image server (could be nginx, a CDN, Amazon S3, etc.). 将图像从应用程序服务器传输/部署到图像服务器(可以是nginx,CDN,Amazon S3等)。
  • Update the DB record with the location of the image to be loaded by the client. 使用客户端要加载的映像的位置更新数据库记录。
  • Delete the temporary file from the application server. 从应用程序服务器中删除临时文件。

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. 这样,HTTP客户端只会与保留所有业务逻辑/安全性/访问控制等的应用服务器进行通信。它仅从映像服务器读取。

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). 实际上,让用户直接写入图像服务器可能会带来安全风险,因为这种类型的服务器通常对上载的内容没有太多控制权(与应用程序服务器不同)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM