Hi,
I am using nginx to protect the elasticsearch. When trying to access elasticsearch in client js. Its throwing Unable to revive connection: http://ubuntulocal:80:9200/ error.
My question is how to connect the elasticsearch using client js behind the nginx proxy ?
node js code
var elasticsearch = require('elasticsearch');
var host = [
{
host: 'http://ubunutlocal:80',
auth: 'root:root'
}]
var client = new elasticsearch.Client({
host: host
});
client.search({
index : 'bank'
// undocumented params are appended to the query string
//hello: "elasticsearch"
}, function (error , response) {
if (error) {
console.error('elasticsearch cluster is down!' , error);
} else {
console.log('All is well' , response);
}
});
Error log
Elasticsearch ERROR: 2015-10-26T13:14:06Z
Error: Request error, retrying -- getaddrinfo ENOTFOUND ubuntulocal:80
at Log.error (/node_modules/elasticsearch/src/lib/log.js:213:60)
at checkRespForFailure (/node_modules/elasticsearch/src/lib/transport.js:192:18)
at HttpConnector. (
/node_modules/elasticsearch/src/lib/connectors/http.js:153:7)
at ClientRequest.wrapper (
node_modules/elasticsearch/node_modules/lodash/index.js:3111:19)
at ClientRequest.emit (events.js:107:17)
at Socket.socketErrorListener (_http_client.js:271:9)
at Socket.emit (events.js:107:17)
at net.js:950:16
at process._tickCallback (node.js:355:11)
Elasticsearch WARNING: 2015-10-26T13:14:06Z
Unable to revive connection: http://ubuntulocal:80:9200/
Elasticsearch WARNING: 2015-10-26T13:14:06Z
No living connections
elasticsearch cluster is down! { [Error: No Living connections] message: 'No Living connections' }