ElasticHQ / elasticsearch-HQ

Monitoring and Management Web Application for ElasticSearch instances and clusters.
http://www.elastichq.org
Other
4.97k stars 532 forks source link

Fixes #527: Allow suburl to map the application #528

Open Yunha-Lee opened 4 years ago

Yunha-Lee commented 4 years ago

Instructions

Please try and perform pull requests against the develop branch.

Merging against the master branch causes a new release to be deployed, and I'd like to avoid that on every PR.

PR Details

Fixed an issue where the base url was ignored when calling the websocket api of the metrics page when accessing through a reverse proxy

Description

As already pointed out in issue #527, when accessing through a reverse proxy, when a url with a base path is used, the base path is ignored and the metrics page is not properly loaded. (e.g. https://www.example.com/elastichq)

The reason is that the subpath of the url entered when establishing a connection to the socket.io is recognized as a namespace. In order to use the subpath of the reverse proxy as it is, a custom path must be set separately. For example, if you enter url as the following, the socket will connect to the elastichq namespace.

this.socket = io("https://www.example.com/elastichq");

To include elastichq in the custom path as intended, it should be modified as follows.

this.socket = io("https://www.example.com", { path: "elastichq/socket.io" });

So, I separated the url part and the baseurl part, and modified it to establish the connection in the correct way. I tested through the nginx proxy environment of kubernetes, and it worked fine in my case. There seems to be a lot of similar questions, so I send a pull request with the modified version. If there is anything wrong, please comment. I hope it helps.

Related Issue

https://github.com/ElasticHQ/elasticsearch-HQ/issues/527