0

I want to query my data indexed by elasticsearch in Lucene engine, but I want this connection to be secure by using SSL:

https://x.y.z.w:9200/index_name/_search?&q=field:value

And this is my whole code:

<!doctype html>
<html lang="fa">
   <head>
    <title>XHR App Test</title>
    <script>
       function send() {
            var xhr = new XMLHttpRequest(),
            url = 'https://x.y.z.w:9200/index_name/_search?&q=field:value',
            sendButton = document.getElementById('sendButton');

        xhr.onreadystatechange = function(e) { 
            console.log(e);
            if (e.currentTarget.readyState > 2) {
                document.getElementById('result').innerHTML = e.currentTarget.responseText;
            }
        };
        xhr.open('GET', url, true);
        xhr.send(null);
    }
    </script>
  </head>
  <body>
     <h1>XHR App Test</h1>

     <button id='sendButton' onclick="send()">Send</button>
     <div id="result"></div>

  </body>
</html>

I also added these configs in elasticsearch.yml file:

 http.port: 9200
 http.cors.enabled : true
 http.cors.allow-origin: /https?:\/\//
 http.cors.allow-methods : OPTIONS, HEAD, GET, POST, PUT, DELETE
 http.cors.allow-headers : "X-Requested-With,X-Auth-Token,Content-Type, Content-Length, Authorization"
# http.cors.allow-credentials : true

But only be able to query by http protocol not https.

How to resolve this?

4

1 Answer 1

1

Elasticsearch doesn't support SSL out-of-the-box. The http.cors settings are for enabling and setting up the CORS (Cross-origin resource sharing) mechanism but have nothing to do with SSL.

If you want your ES cluster to serve requests over HTTPS/SSL, you need to setup SSL/TLS either using the Shield plugin or preferably with XPack if you're running ES 5.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.