0

I'm using Elasticsearch 5.6.2 on Ubuntu 16.04.3 LTS running in Azure VM.

I've cloned, built and started elasticsearch-head as posted here - https://github.com/mobz/elasticsearch-head#running-with-built-in-server

After that HEAD seems to be running on http://localhost:9100/ only, but I need it to be available on http://public_ip:9100/ as well.

How can I do so?

kagarlickij
  • 7,327
  • 10
  • 36
  • 71
  • Check the app.js file, it seems to be taking a base URI from configuration, I have not gone through the code base entirely, however, if you could locate the config file, then probably you could change it or if there is no config file, perhaps you can provide one. this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://localhost:9200"; – Ironluca Oct 02 '17 at 07:28
  • Yep, it seems like app-base_uri in app.js is taken from some config, but can't find relevant config( – kagarlickij Oct 02 '17 at 08:03

1 Answers1

1

Replace this code in your GruntFile:

    connect: {
        server: {
            options: {
                port: 9100,
                base: '.',
                keepalive: true
            }
        }
    }

with:

    connect: {
        server: {
            options: {
                hostname:'<your_host_name>',
                port: 9100,
                base: '.',
                keepalive: true
            }
        }
    }

And then re-run your head plugin. For most cloud platforms, the hostname is the private IP for the instance.

  • Thanks, it's almost did the tricks - works fine in hostname is "elasticsearch0" - http://prntscr.com/gs85qb but fails if hostname is "elasticsearch0.westeurope.cloudapp.azure.com" - http://prntscr.com/gs85yu – kagarlickij Oct 02 '17 at 09:40
  • and if I add private ip as a hostname it works, but if I add public ip as a hostname it fails – kagarlickij Oct 02 '17 at 09:45
  • I've enabled CORS in elasticsearch config (It looks like this - http://prntscr.com/gs88p8) but it also didn't help – kagarlickij Oct 02 '17 at 09:48
  • well, now Head is up and running, I've set local ip in Gruntfile.js , but it cant connect to Elasticsearch cluster - http://prntscr.com/gs9i9f why? – kagarlickij Oct 02 '17 at 11:40
  • By default, head plugin tries to connect at localhost:9200. To change this you need to pass an additional query param. You could do this as follows: ?base_uri= – Viplov Patney Oct 03 '17 at 07:17
  • even if I run Head on the same machine with elasticsearch? – kagarlickij Oct 03 '17 at 11:28
  • Yes. This is because you are trying to access Elasticsearch from your browser. And your browser doesn't know which address to point the head plugin to. However, if you run Elasticsearch on your local system, head plugin should work right away since it tries to access localhost:9200 by default. – Viplov Patney Oct 03 '17 at 13:29
  • No. Put it in your browser's address. It would look something like this: 13.93.127.116:9100?base_uri= – Viplov Patney Oct 05 '17 at 06:02
  • I've tried http://176.100.16.25:9100?base_uri=13.93.109.241:9200/ where 176.100.16.25 is my laptop's IP and 13.93.109.241is my elasticsearch server IP on which HEAD is running. And it doesn't work( – kagarlickij Oct 05 '17 at 13:45
  • Ok. Could you please give me the public IP of both the systems: 1. Where your head plugin is running 2. Where your elasticsearch is deployed? – Viplov Patney Oct 05 '17 at 13:48
  • Sure, both are running on 13.93.109.241 , Elasticsearch port is 9200, HEAD port is 9100 - http://prntscr.com/gtmcs6 – kagarlickij Oct 05 '17 at 13:58
  • This would be your URL then: 13.93.109.241:9100?base_uri=13.93.109.241:9200 – Viplov Patney Oct 05 '17 at 14:02
  • You need to put the link I sent as the browser address, not the head plugin address. – Viplov Patney Oct 06 '17 at 09:35
  • Check if your 9200 port for the instance is open to your IP. – Viplov Patney Oct 06 '17 at 11:20
  • It is open - http://prntscr.com/gu0tda and I even can work thought the Sense plugin - http://prntscr.com/gu0tl0 – kagarlickij Oct 06 '17 at 12:54
  • Did you enable CORS? Also, hope you restarted the service after updating it? – Viplov Patney Oct 06 '17 at 15:41
  • yep, CORS is enabled - http://prntscr.com/gu6j0b and service was restarted after that – kagarlickij Oct 06 '17 at 19:58
  • Not sure then. Try removing: http.cors.allow-headers: Authorization If that doesn't work too, then I am out of ideas here. I would just do a fresh setup and try to backtrack what went wrong. – Viplov Patney Oct 07 '17 at 07:11
  • Sorry, mate. Can't really think of anything that can go wrong then without actually looking at the system. – Viplov Patney Oct 07 '17 at 09:53
  • yep, that's really wired, will try set everything from scratch – kagarlickij Oct 08 '17 at 08:58
  • All the best, mate. – Viplov Patney Oct 08 '17 at 10:26
  • Many thanks for your help, I'll update this post when I find the solution – kagarlickij Oct 08 '17 at 13:13