Better autodetection of ElasticSearch endpoint URL

Instead of assuming that ElasticSearch endpoint is mounted at root URL of the
host, use the parent location of _plugin/head.

http://host:12345/mounted/here/_plugin/head will look at
http://host:12345/mounted/here/ instead of http://host:12345/