将 elasticsearch 服务直接暴露给客户端或将其置于中间件之后

sho*_*ujs 6 architecture deployment web-deployment elasticsearch

我编写了一个客户端服务器应用程序。我在服务器上设置了一个弹性搜索服务。客户端(iOS 应用程序)从弹性搜索服务查询信息。我有两个选择:

1. put the elastic-search behind a nginx server(as proxy server). 
2. write an app running on the middle-ware to wrap the elastic-search APIs(only 
   certain APIs that will be queried by the client).
Run Code Online (Sandbox Code Playgroud)

对于选项 1,所有的 elastic-search API 将同时暴露给客户端和公众。

我应该采取什么选择?或者还有其他好的做法来处理这种情况吗?

kfi*_*fis 4

在我看来,你永远不应该向公众提供 ES-API。这样,每个人都可以删除您的索引、更改您的映射并做任何他们想做的事情......这简直是危险的。

此外,这个 API 的强大功能对于某些只想执行一些基本操作的客户端来说可能过于复杂。虽然我不知道你的要求,但我建议你将 ES 包装到你自己的 REST-API 中,以满足客户的特定需求。