Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an option to change the root prefix for NodeJS (Phusion Passenger compatibility) #10587

Closed
micoq opened this issue Feb 27, 2017 · 4 comments
Labels
release_note:enhancement Team:Operations Team label for Operations Team

Comments

@micoq
Copy link

micoq commented Feb 27, 2017

The idea is to add an option to change the prefix of Kibana on NodeJS.

For example, it could allow me to access Kibana with the following URL: http://localhost:5601/kibana/node1 instead of http://localhost:5601/

Why do I want to do this instead of using a proxypass ? Because it's required by some modules like Phusion Passenger.

Since Kibana uses a single library for all HTTP request handling (Hapi), this could easily be added by using the global option for all HTTP routes server.realm.modifiers:

/usr/share/kibana/src/server/http/index.js:
server = kbnServer.server = new _hapi2['default'].Server();
[...]
server.realm.modifiers.route.prefix = config.get('server.prefix');

And just an other modification for the internal Elasticsearch proxy, the prefix must be removed before passing the URL to Elasticsearch:

/usr/share/kibana/src/core_plugins/elasticsearch/lib/map_uri.js:
// Quick and dirty example: it could be better to replace only the beginning of the string
var reqSubPath = request.path.replace(serverPrefix,'').replace(proxyPrefix, '');

Kibana 5.2.1 (official RPM file)
Elasticsearch 5.2.1
OS : RHEL 6.8

@micoq micoq changed the title Add an option to change the root prefix for NodeJS (Passenger compatibility) Add an option to change the root prefix for NodeJS (Phusion Passenger compatibility) Feb 27, 2017
@tylersmalley
Copy link
Contributor

Will the configuration key server.basePath accomplish what you're looking for?

Enables you to specify a path to mount Kibana at if you are running behind a proxy. This only affects the URLs generated by Kibana, your proxy is expected to remove the basePath value before forwarding requests to Kibana. This setting cannot end in a slash (/).

@micoq
Copy link
Author

micoq commented Feb 28, 2017

Hello,
server.basePath only changes URLs in generated web pages not the entry point.
Currently, Kibana expects the reverse proxy (Apache, Nginx...) remove the prefix before passing the request to NodeJS. However, some proxies don't support this (like Phusion Passenger). In my situation, I can't use any external rewrite mechanism without doing dirty hacks. I think it could be useful to other people.

Example:
Currently with a proxy which supports url rewrite:

- Client -> Proxy: GET /myprefix/app/kibana
- Proxy: /myprefix/app/kibana -> /app/kibana (url rewrite)
- Proxy -> Kibana: GET /app/kibana
- Kibana -> Client: /myprefix/app/kibana (using server.basePath)

With an entry prefix with a proxy which doesn't support url rewrite:

- Client -> Proxy: GET /myprefix/app/kibana
- Proxy: /myprefix/app/kibana -> /myprefix/app/kibana (no change)
- Proxy -> Kibana: GET /myprefix/app/kibana
- Kibana -> Client: /myprefix/app/kibana (using server.basePath)

Without an entry prefix with a proxy which doesn't support url rewrite:

- Client -> Proxy: GET /myprefix/app/kibana
- Proxy: /myprefix/app/kibana -> /myprefix/app/kibana (no change)
- Proxy -> Kibana: GET /myprefix/app/kibana
- Kibana -> Client: 404 !

@epixa
Copy link
Contributor

epixa commented Mar 6, 2017

This request is totally reasonable, but it isn't a high priority for us at this time. We'd be more than happy to review a pull request for this if anyone's feeling ambitious.

@jbudz
Copy link
Member

jbudz commented Jan 31, 2019

I believe with #16724 we now have support for this. A combination of server.basePath and server.rewriteBasePath: true will perform the rewrite on the Kibana server (instead of requiring a proxy rewrite).

Closing this one out, let me know if there's any issues.

@jbudz jbudz closed this as completed Jan 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release_note:enhancement Team:Operations Team label for Operations Team
Projects
None yet
Development

No branches or pull requests

4 participants