title: Using Cloudfront to expose ElasticSearch REST API in read only (GET/HEAD)
body: <p>I want to let my clients speak directly with ElasticSearch REST API, obviously preventing them from performing any data or configuration change.</p>
  
  <p>I had a look at ElasticSearch REST interface and I noticed the pattern: <a href="http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/docs-get.html" rel="nofollow noreferrer">HTTP GET requests</a> are pretty safe (harmless queries and status of cluster).</p>
  
  <p>So I thought I can use Cloudfront as a CDN/Proxy that <strong>only allows GET/HEAD</strong> methods (you can impose such restrict it in the main configuration).</p>
  
  <p>So far so good, all is set up. But things don't work because I would need to open my EC2 security group to the world in order to be reachable from Cloudfront! I don't want this, really!</p>
  
  <p>When I use EC2 with RDS, I can simply allow access to my EC2 security group in RDS security groups. Why can't I do this with CloudFront? Or can I?</p>
  
  <p>Ideas?</p>
  
  <p><strong>edit</strong>: It's not documented, but ES accepts facets query, which involve a (JSON) body, not only with POST, but also with GET. This simply breaks HTTP recommendation (as for RFC3616) by not ignoring the body for GET request (<a href="https://stackoverflow.com/a/15656884/1094616">source</a>).
  This relates because, as pointed out, exposing ES REST interface directly can lead to easy DOS attacks using complex queries. I'm still convinced though, having one less proxy is still worth it.  </p>
  
  <p><strong>edit</strong>: Other option for me would be to skip CloudFront and adding a security layer as an ElasticSearch plugin as shown <a href="http://blog.brusic.com/2011/09/create-pluggable-rest-endpoints-in.html" rel="nofollow noreferrer">here</a></p>