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?