Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ES-head plugin not working through browser

I'm trying to run the elasticSearch-head plugin on my server, but i just can access it through the server terminal. If i try to access it through a browser, it tries to connect until the "This page is not available" browser message is showed.

If i type "curl -v http://localhost:9200/_plugin/head/" in the terminal, i get

*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 9200 (#0)
> GET /_plugin/head/ HTTP/1.1
> User-Agent: curl/7.36.0
> Host: localhost:9200
> Accept: */*
>
< HTTP/1.1 200 OK
< Content-Type: text/html
< Content-Length: 1077
<
<!DOCTYPE html>

<html>
        <head>
                <meta charset="UTF-8">
                <title>elasticsearch-head</title>
                <link rel="stylesheet" href="dist/base/reset.css">
                <link rel="stylesheet" href="dist/vendor.css">
                <link rel="stylesheet" href="dist/app.css">
                <script src="dist/i18n.js" data-baseDir="dist/lang" data-langs="en,fr,pt"></script>
                <script src="dist/vendor.js"></script>
                <script src="dist/app.js"></script>
                <script>
                        window.onload = function() {
                                if(location.href.contains("/_plugin/")) {
                                        var base_uri = location.href.replace(/_plugin\/.*/, '');
                                }
                                var args = location.search.substring(1).split("&").reduce(function(r, p) {
                                        r[decodeURIComponent(p.split("=")[0])] = decodeURIComponent(p.split("=")[1]); return r;
                                }, {});
                                new app.App("body", {
                                        id: "es",
                                        base_uri: args["base_uri"] || base_uri,
                                        auth_user : args["auth_user"] || "",
                                        auth_password : args["auth_password"],
                                        dashboard: args["dashboard"]
                                });
                        };
                </script>
                <link rel="icon" href="dist/base/favicon.png" type="image/png">
        </head>
        <body></body>
</html>
* Connection #0 to host localhost left intact

But if i go to a browser and i type: X.X.X.X:9200/_plugin/head/ it just dont show anything.

What im missing here? Any guess?

Thank you in advance.

like image 808
Miguel Cantó Bataller Avatar asked Sep 05 '14 09:09

Miguel Cantó Bataller


3 Answers

I faced the same problem. I was using chrome. Developer tools in chrome pointed me this error

XMLHttpRequest cannot load http://localhost:9200/_cluster/health. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.

One of the suggested answer on stackoverflow for the above error was to use the below chrome extension to enable and disable CORS on a as needed basis. When this extension was enabled elastic-head started working in chrome.

https://chrome.google.com/webstore/detail/allow-control-allow-origi/nlfbmbojpeacfghkpbjhddihlkkiljbi/related?hl=en-US

like image 93
srikanth Avatar answered Oct 17 '22 15:10

srikanth


I faced the same issue after googling for hours I found that you need to restart your elasticsearch nodes but before you do that make sure to shutdown the elasticsearch by running

curl -XPOST localhost:9200/_shutdown

Then start your elasticsearch with

sudo ./elasticsearch
like image 1
Shashank K Avatar answered Oct 17 '22 17:10

Shashank K


I've found that (at least with the 2.x versions, I can't speak to earlier) you don't need to bounce elasticsearch after installing the head plugin. The issue for me was that for whatever reason, I couldn't connect over localhost:9200 but could via my network IP address. The way I was able to figure this out was via netstat -na | grep 9200.

Again, why it chose to do this, I can't confirm - I matched my /etc/hosts file with my work desktop and my work desktop doesn't have any issues connecting via localhost.

The other thing I had to do was to change was the transport address from localhost to my network IP as well or I got a NoSuchNodeException on startup.

like image 1
icfantv Avatar answered Oct 17 '22 17:10

icfantv