Open jplu opened 7 years ago
vi config/elasticsearch.yml
Write the following lines: http.cors.enabled: true http.cors.allow-origin: "*"
Thanks @NicolJiang for your reply.
As you can see in my previous post my config/elasticsearch.yml
file already contains these lines. Any other idea?
Try to delete http.cors.allow-methods & http.cors.allow-headers?
The same behavior, nothing has changed.
Just want to confirm, are your elasticsearch-head running in the same machine as your elasticsearch cluster?
My elasticsearch Cluster is in a Docker container on the same machine, yes.
any update on this?
Running ELK stack 5.2.1 in docker container while setting
http.cors.enabled: true
http.cors.allow-origin: "*"
in elasticsearch.yml
and getting cluster health: not connected
error.
Are there any means to fully debug this issue? Even if I set grunt to debug and verbose mode I do not see any requests.
Elastic stack 5.2.1 works fine though.
Tried all possible settings and configurations possible with regard to topics revolving around this and comparable issues, but sadly no luck π’
Connection requests are not forwarded to the remote host (as expected and how the plugin worked) but are forwarded to the local host which of course denies the request since nothing runs on :9200. A connect to http://remotehost:port
works fine. So either the concept is totally different from the plugin or it is a bug.
@mobz Can you have a look at this please? Did I (we) get the concept of the stand-alone server wrong? Thanks in advance :bowtie:
Console shows the following errors.
GET http://localhost:9200/ net::ERR_CONNECTION_REFUSED
(anonymous) @ VM597:2
send @ vendor.js:7829
ajax @ vendor.js:7307
request @ app.js:1303
get @ app.js:1313
init @ app.js:3746
prototype.(anonymous function) @ app.js:281
Class @ app.js:265
init @ app.js:4137
Class @ app.js:265
init @ app.js:4346
prototype.(anonymous function) @ app.js:281
Class @ app.js:265
window.onload @ (index):21
app.js:1308 Object {XHR Error: "error", message: ""}
VM597:2 GET http://localhost:9200/_cluster/state net::ERR_CONNECTION_REFUSED
(anonymous) @ VM597:2
send @ vendor.js:7829
ajax @ vendor.js:7307
request @ app.js:1303
get @ app.js:1313
refresh @ app.js:1351
init @ app.js:4183
Class @ app.js:265
init @ app.js:4346
prototype.(anonymous function) @ app.js:281
Class @ app.js:265
window.onload @ (index):21
VM597:2 GET http://localhost:9200/_stats net::ERR_CONNECTION_REFUSED
(anonymous) @ VM597:2
send @ vendor.js:7829
ajax @ vendor.js:7307
request @ app.js:1303
get @ app.js:1313
refresh @ app.js:1380
init @ app.js:4183
Class @ app.js:265
init @ app.js:4346
prototype.(anonymous function) @ app.js:281
Class @ app.js:265
window.onload @ (index):21
app.js:1308 Object {XHR Error: "error", message: ""}
VM597:2 GET http://localhost:9200/_nodes/stats net::ERR_CONNECTION_REFUSED
(anonymous) @ VM597:2
send @ vendor.js:7829
ajax @ vendor.js:7307
request @ app.js:1303
get @ app.js:1313
refresh @ app.js:1384
init @ app.js:4183
Class @ app.js:265
init @ app.js:4346
prototype.(anonymous function) @ app.js:281
Class @ app.js:265
window.onload @ (index):21
app.js:1308 Object {XHR Error: "error", message: ""}
VM597:2 GET http://localhost:9200/_nodes net::ERR_CONNECTION_REFUSED
(anonymous) @ VM597:2
send @ vendor.js:7829
ajax @ vendor.js:7307
request @ app.js:1303
get @ app.js:1313
refresh @ app.js:1388
init @ app.js:4183
Class @ app.js:265
init @ app.js:4346
prototype.(anonymous function) @ app.js:281
Class @ app.js:265
window.onload @ (index):21
app.js:1308 Object {XHR Error: "error", message: ""}
VM597:2 GET http://localhost:9200/_cluster/health net::ERR_CONNECTION_REFUSED
(anonymous) @ VM597:2
send @ vendor.js:7829
ajax @ vendor.js:7307
request @ app.js:1303
get @ app.js:1313
refresh @ app.js:1392
init @ app.js:4183
Class @ app.js:265
init @ app.js:4346
prototype.(anonymous function) @ app.js:281
Class @ app.js:265
window.onload @ (index):21
app.js:1308 Object {XHR Error: "error", message: ""}
It really looks like you have a misconfigured CORS settings. couple of things to try;
1) from the same user space as your browser run;
curl -v -XOPTIONS -H 'Access-Control-Request-Method: GET' -H 'Origin: http://localhost:9100' http://localhost:9201/
This should show whether your elasticsearch is sending correct CORS headers
2) Try is running the new experimental proxy that I'm building into 'head That should allow you to bypass CORS problems altogether. Any feedback on the proxy is welcome. See the README for instructions as to running it. It's pretty raw and requires manually editing config files, but see how you go
@t3chn0m4g3 Also be aware that running with 'standalone server' the browser is making a connection DIRECTLY to elasticsearch, the grunt server just serves the static files.
@mobz Thanks for your swift response and clarification! For my case I think the experimental proxy will be suited best then. However using NGINX as a reverse proxy for the DIRECT
request might also solve the issue, hence it will not be as straight forward to use.
Thank you for Head! Served me very well so far π
@mobz After doing:
curl -v -XOPTIONS -H 'Access-Control-Request-Method: GET' -H 'Origin: http://localhost:9100' http://localhost:9201/
Here what I get:
* Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 9201 (#0)
> OPTIONS / HTTP/1.1
> Host: localhost:9201
> User-Agent: curl/7.52.1
> Accept: */*
> Access-Control-Request-Method: GET
> Origin: http://localhost:9100
>
< HTTP/1.1 200 OK
< access-control-allow-origin: *
< access-control-allow-methods: HEAD,DELETE,POST,GET,OPTIONS,PUT
< access-control-allow-headers: X-Requested-With,X-Auth-Token, Content-Length,Content-Type
< access-control-max-age: 1728000
< date: "Mon, 27 Feb 2017 14:04:03 GMT"
< content-length: 0
<
* Curl_http_done: called premature == 0
* Connection #0 to host localhost left intact
Everything seems to be ok from the Elasticsearch CORS headers. Waiting this new proxy feature then :)
The proxy did not work for me, so I use the standalone server with NGINX as a reverse proxy (exposing ES on 127.0.0.1:9200, basic auth enabled) now.
For NGINX:
### ES
location /es/ {
proxy_pass http://localhost:64298/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-NginX-Proxy true;
rewrite /es/(.*)$ /$1 break;
}
Docker:
/usr/bin/docker run --cap-add=IPC_LOCK --ulimit memlock=-1:-1 --ulimit nofile=65536:65536 -e "ES_JAVA_OPTS=-Xms512m -Xmx512m" --name=elk -v /data:/data -p 127.0.0.1:64296:5601 -p 127.0.0.1:64302:9100 -p 127.0.0.1:64298:9200 --rm=true dtagdevsec/elk:latest1610
@mobz Thanks for your help and pushing me in the right direction π
The same issue for me today, I'm on macOS with brew-installed elasticsearch of version 5.2.2.
I'm finally be able to resolve this issue by adding the two lines setting mentioned above into the config file of brew version elasticsearch.
/usr/local/etc/elasticsearch/elasticsearch.yml
I have the same issue as it's mentioned in above comment. The ES URL isn't replaced properly within the cluster.
Proxy is running
> elasticsearch-head@0.0.0 proxy /opt/elasticsearch-head
> node proxy/index.js
creating proxy localhost:9200
remote: http://10.95.0.19:9200
local: http://localhost:9101
Elasticsearch-head running on standard 9100.
I had the same CORS issue with a vanilla instance of elk5 and head running in the same server. After i read @NicolJiang answer and the tune section of https://hub.docker.com/r/dafire/docker-elk-elasticsearch/, I was able to correct the issue with the following steps:
...
http.cors.enabled: true
http.cors.allow-origin: "*"
elasticsearch:
...
volumes:
- ./elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
docker-compose up -d
docker exec -ti aff2325cb77d bash
bash-4.3$ cat config/elasticsearch.yml
...
http.cors.enabled: true
http.cors.allow-origin: "*"
@mobz Thanks for your amazing job !
Hi guys,
I have the same issue with Elasticsearch 5.3 installed on Centos 7 x64 server.
I started Head plugin with built-in web server, following next steps:
git clone git://github.com/mobz/elasticsearch-head.git
cd elasticsearch-head
npm install
npm run start
After trying to connect to http://localhost:9200/, Head is giving message
cluster health: not connected
At my /etc/elasticsearch/elasticsearch.yml file there are added following two lines:
http.cors.enabled: true
http.cors.allow-origin: "*"
I do not use dockerized environment.
Can somebody help me to get Head plugin working with actual Elasticsearch version?
Thank you
@jovanmal: it should be http://localhost:9100
I just tested on Elasticsearch 5.3 and Centos 7. It works fine on my machine.
What is your node version? I tested on node v6.10.1.
I can open web interface on http://localhost:9100, but cannot connect to Elasticsearch from it. Screenshot attached.
Node version? When I execute command
get _nodes
in Kibana, getting following output:
{
"_nodes": {
"total": 1,
"successful": 1,
"failed": 0
},
"cluster_name": "elasticsearch",
"nodes": {
"Xbw_S7vsSD-5SXeV2PYicg": {
"name": "Xbw_S7v",
"transport_address": "127.0.0.1:9300",
"host": "localhost",
"ip": "127.0.0.1",
"version": "5.3.0",
"build_hash": "3adb13b",
"total_indexing_buffer": 213005107,
"roles": [
"master",
"data",
"ingest"
],
"settings": {
"pidfile": "/var/run/elasticsearch/elasticsearch.pid",
"cluster": {
"name": "elasticsearch"
},
"node": {
"name": "Xbw_S7v"
},
"path": {
"conf": "/etc/elasticsearch",
"data": [
"/var/lib/elasticsearch"
],
"logs": "/var/log/elasticsearch",
"home": "/usr/share/elasticsearch"
},
"client": {
"type": "node"
},
"http": {
"type": {
"default": "netty4"
},
"port": "9200"
},
"bootstrap": {
"memory_lock": "true"
},
"transport": {
"type": {
"default": "netty4"
}
},
"network": {
"host": "localhost"
}
},
"os": {
"refresh_interval_in_millis": 1000,
"name": "Linux",
"arch": "amd64",
"version": "3.10.0-514.10.2.el7.x86_64",
"available_processors": 2,
"allocated_processors": 2
},
"process": {
"refresh_interval_in_millis": 1000,
"id": 945,
"mlockall": true
},
"jvm": {
"pid": 945,
"version": "1.8.0_121",
"vm_name": "Java HotSpot(TM) 64-Bit Server VM",
"vm_version": "25.121-b13",
"vm_vendor": "Oracle Corporation",
"start_time_in_millis": 1493092545169,
"mem": {
"heap_init_in_bytes": 2147483648,
"heap_max_in_bytes": 2130051072,
"non_heap_init_in_bytes": 2555904,
"non_heap_max_in_bytes": 0,
"direct_max_in_bytes": 2130051072
},
"gc_collectors": [
"ParNew",
"ConcurrentMarkSweep"
],
"memory_pools": [
"Code Cache",
"Metaspace",
"Compressed Class Space",
"Par Eden Space",
"Par Survivor Space",
"CMS Old Gen"
],
"using_compressed_ordinary_object_pointers": "true"
},
"thread_pool": {
"force_merge": {
"type": "fixed",
"min": 1,
"max": 1,
"queue_size": -1
},
"fetch_shard_started": {
"type": "scaling",
"min": 1,
"max": 4,
"keep_alive": "5m",
"queue_size": -1
},
"listener": {
"type": "fixed",
"min": 1,
"max": 1,
"queue_size": -1
},
"index": {
"type": "fixed",
"min": 2,
"max": 2,
"queue_size": 200
},
"refresh": {
"type": "scaling",
"min": 1,
"max": 1,
"keep_alive": "5m",
"queue_size": -1
},
"generic": {
"type": "scaling",
"min": 4,
"max": 128,
"keep_alive": "30s",
"queue_size": -1
},
"warmer": {
"type": "scaling",
"min": 1,
"max": 1,
"keep_alive": "5m",
"queue_size": -1
},
"search": {
"type": "fixed",
"min": 4,
"max": 4,
"queue_size": 1000
},
"flush": {
"type": "scaling",
"min": 1,
"max": 1,
"keep_alive": "5m",
"queue_size": -1
},
"fetch_shard_store": {
"type": "scaling",
"min": 1,
"max": 4,
"keep_alive": "5m",
"queue_size": -1
},
"management": {
"type": "scaling",
"min": 1,
"max": 5,
"keep_alive": "5m",
"queue_size": -1
},
"get": {
"type": "fixed",
"min": 2,
"max": 2,
"queue_size": 1000
},
"bulk": {
"type": "fixed",
"min": 2,
"max": 2,
"queue_size": 200
},
"snapshot": {
"type": "scaling",
"min": 1,
"max": 1,
"keep_alive": "5m",
"queue_size": -1
}
},
"transport": {
"bound_address": [
"127.0.0.1:9300",
"[::1]:9300"
],
"publish_address": "127.0.0.1:9300",
"profiles": {}
},
"http": {
"bound_address": [
"127.0.0.1:9200",
"[::1]:9200"
],
"publish_address": "127.0.0.1:9200",
"max_content_length_in_bytes": 104857600
},
"plugins": [
{
"name": "ingest-geoip",
"version": "5.3.0",
"description": "Ingest processor that uses looksup geo data based on ip adresses using the Maxmind geo database",
"classname": "org.elasticsearch.ingest.geoip.IngestGeoIpPlugin"
},
{
"name": "ingest-user-agent",
"version": "5.3.0",
"description": "Ingest processor that extracts information from a user agent",
"classname": "org.elasticsearch.ingest.useragent.IngestUserAgentPlugin"
}
],
"modules": [
{
"name": "aggs-matrix-stats",
"version": "5.3.0",
"description": "Adds aggregations whose input are a list of numeric fields and output includes a matrix.",
"classname": "org.elasticsearch.search.aggregations.matrix.MatrixAggregationPlugin"
},
{
"name": "ingest-common",
"version": "5.3.0",
"description": "Module for ingest processors that do not require additional security permissions or have large dependencies and resources",
"classname": "org.elasticsearch.ingest.common.IngestCommonPlugin"
},
{
"name": "lang-expression",
"version": "5.3.0",
"description": "Lucene expressions integration for Elasticsearch",
"classname": "org.elasticsearch.script.expression.ExpressionPlugin"
},
{
"name": "lang-groovy",
"version": "5.3.0",
"description": "Groovy scripting integration for Elasticsearch",
"classname": "org.elasticsearch.script.groovy.GroovyPlugin"
},
{
"name": "lang-mustache",
"version": "5.3.0",
"description": "Mustache scripting integration for Elasticsearch",
"classname": "org.elasticsearch.script.mustache.MustachePlugin"
},
{
"name": "lang-painless",
"version": "5.3.0",
"description": "An easy, safe and fast scripting language for Elasticsearch",
"classname": "org.elasticsearch.painless.PainlessPlugin"
},
{
"name": "percolator",
"version": "5.3.0",
"description": "Percolator module adds capability to index queries and query these queries by specifying documents",
"classname": "org.elasticsearch.percolator.PercolatorPlugin"
},
{
"name": "reindex",
"version": "5.3.0",
"description": "The Reindex module adds APIs to reindex from one index to another or update documents in place.",
"classname": "org.elasticsearch.index.reindex.ReindexPlugin"
},
{
"name": "transport-netty3",
"version": "5.3.0",
"description": "Netty 3 based transport implementation",
"classname": "org.elasticsearch.transport.Netty3Plugin"
},
{
"name": "transport-netty4",
"version": "5.3.0",
"description": "Netty 4 based transport implementation",
"classname": "org.elasticsearch.transport.Netty4Plugin"
}
],
"ingest": {
"processors": [
{
"type": "append"
},
{
"type": "convert"
},
{
"type": "date"
},
{
"type": "date_index_name"
},
{
"type": "dot_expander"
},
{
"type": "fail"
},
{
"type": "foreach"
},
{
"type": "geoip"
},
{
"type": "grok"
},
{
"type": "gsub"
},
{
"type": "join"
},
{
"type": "json"
},
{
"type": "kv"
},
{
"type": "lowercase"
},
{
"type": "remove"
},
{
"type": "rename"
},
{
"type": "script"
},
{
"type": "set"
},
{
"type": "sort"
},
{
"type": "split"
},
{
"type": "trim"
},
{
"type": "uppercase"
},
{
"type": "user_agent"
}
]
}
}
}
}
In my case, version is 5.3.0, as you can see from output.
@jovanmal: can you check what's the error message in the Chrome console tab? To open the console use Ctrl+Shift+I (linux) or Command+Option+I (mac), go to console tab, and refresh the page.
Yes, of course. There are multiple "net::ERR_CONNECTION_REFUSED" messages.
Screenshot enclosed.
Thank you
@jovanmal: looks like you connect to 192.168.6.186. Can you connect to http://192.168.6.186:9200
instead of http://localhost:9200
.
@philipskokoh, thank you very much for your time.
yes, I tried to connect from web browser and got error
This site canβt be reached 192.168.6.186 refused to connect.
Elasticsearch is working. Logstash successfully sending parsed data to http://192.168.6.186:9200
, but getting error when try to connect from the any web browser to it.
@jovanmal: not the url in web browser, but the edit box beside connect button.
Alternatively, you can use url parameter: 192.168.6.186:9100/index.html?base_uri=http://192.168.6.186:9200
Reference:
https://github.com/mobz/elasticsearch-head#url-parameters
@philipskokoh I have the same issue as @jovanmal that is:
172.16.30.247:9100
cluster health : not connected ,the head-plugin is a standalone server,my elasticsearch version is 5.2.0 .
http.cors.enabled: true, http.cors.allow-origin: "*"
net::ERR_CONNECTION_REFUSED
,
the screenshot is totally the same ,I try visit 172.16.30.247:9200
,it shows { "name" : "node01-247", "cluster_name" : "dev-elastic", "cluster_uuid" : "3lf0enLJR6S3VoXGFze8OQ", "version" : { "number" : "5.2.0", "build_hash" : "24e05b9", "build_date" : "2017-01-24T19:52:35.800Z", "build_snapshot" : false, "lucene_version" : "6.4.0" }, "tagline" : "You Know, for Search" }
So could you give me a hand?Ty:)@cgyim1992: have you tried using base_uri
? It should work.
https://github.com/mobz/elasticsearch-head/issues/308#issuecomment-297626065
@philipskokoh Yep,i try what you suggested,and it works! π but :( I have met another problem: my elasticsearch cluster is deployed in public cloud, so i have a nginx to proxy my elasticsearch_addr:9200 to http://search.wapercor.com ,however in order to ensure least safety,nginx requires a basic password auth,but as image shows ,the http request seems not able to send user and password ,and add user and password in url is not secure,so dude,could you give me some help?tyty:):)
I have installed EKL stack on mac using brew and installed elasticsearch-head plugin. At the start it was not connected. By adding updating elasticsearch.yml. It is able to connect to elasticsearch on localhost.
@jplu Hello,did you put the elasticsearch-head in the offical directory /elasticsearch/plugins?I think you can try to put the elasticsearch-head in any directory created by yourself,then start the elasticsearch-head.
I encountered the following error the moment I tried to start elasticsearch-head.
# npm run start
> elasticsearch-head@0.0.0 start /usr/local/elastic/es-head/elasticsearch-head
> grunt server
Running "connect:server" (connect) task
Waiting forever...
Fatal error: Port 9100 is already in use by another process.
At first glance, it looks like it's just a port conflict. Fatal error: Port 9100 is already in use by another process.
# ss -anp | grep "9100"
tcp LISTEN 0 128 :9100 *: users:(("node",pid=20056,fd=12))
# ps aux | grep "20056"
root 11003 0.0 0.0 112824 976 pts/4 S+ 12:01 0:00 grep --color=auto 20056
root 20056 0.0 0.0 996864 1736 ? Sl Feb 24 0:01 grunt
However, even if I kill the grunt process, elasticsearch-head doesn't start. And the grunt process comes back again.
What should I do?
Hello,
I do have an up and working Elasticsearch cluster:
Error the errors I get in the Javascript Console:
I get these errors on Chrome and Firefox. I added the following lines in my
elasticsearch.yml
:Any idea of what is going wrong?