elastic / kibana

Your window into the Elastic Stack
https://www.elastic.co/products/kibana
Other
19.6k stars 8.22k forks source link

Http and https hosts not supported for console proxy together #158727

Open K1vs opened 1 year ago

K1vs commented 1 year ago

Kibana version: <=8.8.0

Elasticsearch version: any

Server OS version: any

Browser version: any

Browser OS version: any

Original install method (e.g. download page, yum, from source, etc.): k8s https://www.elastic.co/guide/en/cloud-on-k8s/current/k8s-deploy-kibana.html

Describe the bug: Http and https hosts not supported for console plugin proxy together. And although the configuration is created for each host separately, the agent is created based on the first host in the list. Which will result in an ERR_INVALID_PROTOCOL error if there are hosts with different protocols in the list of hosts.

https://github.com/elastic/kibana/blob/main/src/plugins/console/server/lib/elasticsearch_proxy_config.ts#L17

image image

https://github.com/elastic/kibana/blob/main/src/plugins/console/server/routes/api/console/proxy/create_handler.ts#L68

image image

Steps to reproduce:

  1. Configure hosts with diffent protocol. E.g. first with https://ahost.dev, and second with http://bhost.dev
  2. Shutdows first configured host with https protocol (e.g https://ahost.dev).
  3. Try use dev tools console /app/dev_tools#/console
  4. Protocol \"http:\" not supported. Expected \"https:\"

Expected behavior: Succesfull using dev tools with second host (http://bhost.dev).

Screenshots (if relevant):

image

Errors in browser console (if relevant):

image

Provide logs and/or server output (if relevant): [2023-05-31T10:07:20.011+00:00][ERROR][plugins.console] Error: connect ECONNREFUSED 10.2.0.202:9200     at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1278:16)     at TCPConnectWrap.callbackTrampoline (node:internal/async_hooks:130:17) [2023-05-31T10:07:20.012+00:00][ERROR][plugins.console] TypeError: Protocol "http:" not supported. Expected "https:"     at new NodeError (node:internal/errors:387:5)     at new ClientRequest (node:_http_client:186:11)     at Object.request (node:http:97:10)     at Object.request (/usr/share/kibana/node_modules/elastic-apm-node/lib/instrumentation/http-shared.js:224:21)     at proxyRequest (/usr/share/kibana/node_modules/@kbn/console-plugin/server/lib/proxy_request.js:54:22)     at /usr/share/kibana/node_modules/@kbn/console-plugin/server/routes/api/console/proxy/create_handler.js:135:55     at runMicrotasks ()     at processTicksAndRejections (node:internal/process/task_queues:96:5)     at Router.handle (/usr/share/kibana/node_modules/@kbn/core-http-router-server-internal/src/router.js:149:30)     at handler (/usr/share/kibana/node_modules/@kbn/core-http-router-server-internal/src/router.js:115:50)     at exports.Manager.execute (/usr/share/kibana/node_modules/@hapi/hapi/lib/toolkit.js:60:28)     at Object.internals.handler (/usr/share/kibana/node_modules/@hapi/hapi/lib/handler.js:46:20)     at exports.execute (/usr/share/kibana/node_modules/@hapi/hapi/lib/handler.js:31:20)     at Request._lifecycle (/usr/share/kibana/node_modules/@hapi/hapi/lib/request.js:371:32)     at Request._execute (/usr/share/kibana/node_modules/@hapi/hapi/lib/request.js:281:9) [2023-05-31T10:07:20.014+00:00][WARN ][plugins.console] Could not connect to any configured ES node

Any additional context: I don't need both protocols in the hosts, but the https host is automatically added first when deployed to k8s. Why this addition happens is not clear to me, but it does not interfere with the work of other kibana functionality, but because of the bug described above, it turned out to be critical for the console.

elasticmachine commented 1 year ago

Pinging @elastic/platform-deployment-management (Team:Deployment Management)

ebuildy commented 1 year ago

guys this is a serious bug !!!

We cannot secure properly elasticsearch stack and use kibana devtools, all Kibana stuff are OK.

(ECK 2.9 / Kibana 8.8.1 / Licence)

elasticmachine commented 1 month ago

Pinging @elastic/kibana-management (Team:Kibana Management)