Kibana deployment issue on server . . . client not

2019-06-28 09:06发布

问题:

I have configured Logstash + ES + kibana on 100.100.0.158 VM and Kibana is running under apache server. port 8080

Now what my need is . . I just have to give URL "100.100.0.158:8080/kibana" to client so client can see his data on web.

When when I put this URL on client browser I am getting this error "can't contact elasticsearch at http://"127.0.0.1":9200 please ensure that elastic search is reachable from your system"

Do I need to configure ES with IP 100.100.0.158:9200 or 127.0.0.1:9200 is ok . . !

Help . . !

Thanks Tushar

回答1:

If your Kibana and ES are installed on the same box, you can have it auto-detect the the ES URL/IP by using this line in your Kibana's config.js file:

/** @scratch /configuration/config.js/5
 * ==== elasticsearch
 *
 * The URL to your elasticsearch server. You almost certainly don't
 * want +http://localhost:9200+ here. Even if Kibana and Elasticsearch are on
 * the same host. By default this will attempt to reach ES at the same host you have
 * elasticsearch installed on. You probably want to set it to the FQDN of your
 * elasticsearch host
 */
elasticsearch: "http://"+window.location.hostname+":9200",

This is because the interface between Kibana and ES is via JavaScript, and so using 127.0.0.1 or localhost actually points to the client machine (that the browser is running on) rather than the server.



回答2:

Modify elasticsearch configuration file elasticsearch.yml

Append or modify following configurations:

# Enable or disable cross-origin resource sharing.
http.cors.enabled: true

# Which origins to allow.
http.cors.allow-origin: /https?:\/\/<*your\.kibana\.host*>(:[0-9]+)?/

It is caused by kibana page trying to load jason data from elasticsearch which will be blocked for security reason.



回答3:

It is about iptables rules. Kibana uses 9292 for web port, but for elasticsearch queries uses 9200. So you must add line to iptables for these ports.

netstat -napt | grep -i LISTEN

you will see these ports: 9200 9300 9301 9302 9292

iptables -I INPUT 4 -p tcp -m state --state NEW -m tcp --dport 9200 -j ACCEPT

see detail: http://logstash.net/docs/1.3.3/tutorials/getting-started-simple