If your client application will use most or all of the Elasticsearch API, it makes sense to put it behind a proxy, for example, Nginx.
If the client application will work with Elasticsearch in the traditional sense (search, even updating documents), I would prefer to put in front of it a βsmarterβ proxy, i.e. what you call middleware written in Ruby, Python, etc. You have tighter control over the workflow here, although the Nginx proxy is very smart too.
The more important question is whether you agree to provide the Elasticsearch API to the client using HTTP Auth or token-based authentication. Thus, the credentials are clearly visible to the client, can be intercepted, etc.
Here is an example of OAuth-based authentication for Elasticsearch and JavaScript client applications in this article: JavaScript and Elasticsearch Web Applications . It uses Twitter @Anywhere (replaced by Sign in with Twitter) to authenticate the user, preventing him from bypassing the proxy server by intercepting credentials.
karmi source share