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

Configurable application context path to facilitate running behind a reverse proxy #1555

Closed
dimovelev opened this Issue Oct 7, 2014 · 35 comments

Comments

Projects
None yet
@dimovelev

dimovelev commented Oct 7, 2014

Hi,

It would be great if one could configure (config.yml and/or command line argument) the context path under which kibana is running. Currently it is running under root (/) and this makes it hard to put behind a reverse proxy which serves multiple applications under different paths. If the context path were configurable, one could set it to e.g. kibana and configure the reverse proxy to forward requests to /kibana/* to the kibana instance running behind it. Currently that is not possible as the responses (html pages, javascripts, whatever) contain hard coded links which do not work.

Cheers,
Dimo

@rashidkpc rashidkpc added the notabug label Oct 7, 2014

@rashidkpc

This comment has been minimized.

Member

rashidkpc commented Oct 7, 2014

We currently don't plan to introduce a configurable base path. The way to accomplish this would be to use mod_rewrite rules to alter the requests to that path and pass them to the proxy.

@rashidkpc rashidkpc closed this Oct 7, 2014

@bradvido

This comment has been minimized.

bradvido commented Oct 7, 2014

FWIW: I tried using mod_rewrite and Kibana choked. The first http request worked, but then kibana in the browser started to load other resources (css, images, etc), and they didn't use the path from the url, They tried to load directly from / instead of /kibana (where /kibana is my custom path).

It's probably a problem where kibana html & js reference resources a /resource instead of resource

@dimovelev

This comment has been minimized.

dimovelev commented Oct 8, 2014

You cannot effectively use mod_rewrite for this. You would have to parse through javascript, html and maybe other resources and modify everything that looks like a link. That normally fails.

Why don't you want to support such a base feature?

@falkenbt

This comment has been minimized.

falkenbt commented Oct 8, 2014

+1
We are using a reverse proxy (apache->atlassian crowd) to restrict and secure the access to Kibana 3 and ES. We can't upgrade to Kibana 4 with this setup as there is no other good solution I know of to restrict access. Using mod_rewrite is not a proper solution as stated above.

@marminthibaut

This comment has been minimized.

Contributor

marminthibaut commented Nov 12, 2014

+1
Why not add a property in the kibana.yml config file?

@kadishmal

This comment has been minimized.

kadishmal commented Mar 11, 2015

👍 We run Kibana behind HAProxy and encounter the same problem. The client code should use the relative path to request resources.

@rovangju

This comment has been minimized.

rovangju commented Apr 12, 2015

We have SSL certs to consider and making us create more DNS entries for vhosts is making this difficult to use.

@Poohblah

This comment has been minimized.

Poohblah commented Apr 28, 2015

Kibana 3 seems to work just fine behind an Apache reverse proxy for me. The trick is that Kibana sends 302 redirects that you need to catch with a clever set of ProxyPassReverse directives, e.g.:

ProxyPass /kibana-3 http://localhost:9292
ProxyPassReverse /kibana-3/ http://localhost:9292
ProxyPassReverse /kibana-3/ http://my.awesome.website

The "aha" moment for me was realizing that both of the ProxyPassReverse directives were necessary with Kibana 3.

@maximede

This comment has been minimized.

maximede commented May 18, 2015

A quick and easy fix is to add
<base href="/yourcontext/" >

in the header of /src/public/index.html

@arganzheng

This comment has been minimized.

arganzheng commented Jun 29, 2015

+1. Why not add a property in the kibana.yml config file?

@malcolmspiteri

This comment has been minimized.

malcolmspiteri commented Jul 13, 2015

Here's what I did to change the context path. It's kind of dirty but seems to be working and avoids the URL rewrite thing:

Go to src/public
Create a new directory named 'mycontext'
Move all files from src/public to src/public/mycontext
Edit src/app.js and change line 25 to the following:
app.use(favicon(path.join(config.public_folder, 'mycontext', 'styles', 'theme', 'elk.ico')));
Edit src/app.js and change lines 34 and 35 to the following:
app.use('/mycontext/elasticsearch', proxy);
app.use('/mycontext/enforcer', require('./lib/enforce'));
Edit src/routes/index.js and change line 6 to the following:
router.get('/mycontext/config', function (req, res, next) {

The version I'm using is 4.0.2-linux-x64

@nmors

This comment has been minimized.

nmors commented Aug 7, 2015

+1

2 similar comments
@laktak

This comment has been minimized.

laktak commented Sep 1, 2015

+1

@larslorenzen

This comment has been minimized.

larslorenzen commented Sep 17, 2015

+1

@double-p

This comment has been minimized.

double-p commented Sep 17, 2015

welcome modern world and +1

@nabheet

This comment has been minimized.

nabheet commented Nov 2, 2015

+1 running into the same problem with kibana 4.2 and nginx. Interestingly I didn't have this problem with 4.1.2.

@osklil

This comment has been minimized.

osklil commented Nov 2, 2015

+1

@austinkeeley

This comment has been minimized.

austinkeeley commented Nov 3, 2015

@maximede's fix worked for me. As a manual fix, it's not too bad, but it would be nice to have this as a config option to support automated Kibana deployments.

@kodemaniak

This comment has been minimized.

kodemaniak commented Nov 19, 2015

+1
For me it also worked with 4.1.2 and nginx, but with 4.2 it suddenly redirects to another path. I have kibana running under /monitoring/kibana (which worked in 4.1.2 without any problems), but 4.2 redirects to /app/kibana. I actually do not quite understand where that base path comes from.

@louspringer

This comment has been minimized.

louspringer commented Dec 13, 2015

+1

@evangael

This comment has been minimized.

evangael commented Jan 8, 2016

+1 too. Just got this issue trying to set proxypass in nginx.

@mhavrlent

This comment has been minimized.

mhavrlent commented Jan 9, 2016

+1

Solution by @maximede and @Poohblah no longer works in version 4.3.1.
1/ Whole application should be served under /kibana context root by default (not /app/kibana) and this context root should be configurable.
2/ elasticsearch should be served under /kibana/elasticsearch not /elasticsearch.
3/ bundles should be served under /kibana/bundles not /bundles
4/ status should be served under /kibana/status not /status
.. perhaps there are also others, I noticed these so far.

@yacineMTB

This comment has been minimized.

yacineMTB commented Jan 20, 2016

+1

@marnovdm

This comment has been minimized.

marnovdm commented Jan 27, 2016

+1 we need this for production deploys

@jmcollin78

This comment has been minimized.

jmcollin78 commented Feb 5, 2016

+1 the default root context seems to be /app/kibana which is not compatible with our production plan.

@nmors

This comment has been minimized.

nmors commented Feb 5, 2016

This has been working fine for us using apache and in another deployment
nginx as reverse proxy, both with just /kibana/ as the context root. Using
regex match on the path in config fixes it
On 5 Feb 2016 10:59 pm, "Jean-Marc Collin" notifications@github.com wrote:

+1 the default root context seems to be /app/kibana which is not
compatible with our production plan.


Reply to this email directly or view it on GitHub
#1555 (comment).

@jmcollin78

This comment has been minimized.

jmcollin78 commented Feb 5, 2016

Thank's for your answer. It is possible with Apache using RewriteRule. But how can I do that with NGinx that is our Reverse Proxy ?

@jmcollin78

This comment has been minimized.

jmcollin78 commented Feb 5, 2016

I've found a server.basePath config in Kibana 4.4. But whatever I set e value, kibana always answer 404.
For example:
when server.basePath: "/root"

calling
curl http://localhost:5601/
leads to:

<script>var hashRoute = '/root/app/kibana';
var defaultRoute = '/root/app/kibana';

var hash = window.location.hash;
if (hash.length) {
  window.location = hashRoute + hash;
} else {
  window.location = defaultRoute;
}</script>

which sounds good.

But calling
curl http://localhost:5601/root/app/kibana
always give:

{"statusCode":404,"error":"Not Found"}

I trywith leading / with index index.html and I always get a 404.

Any clues will be greatly appreciated.

jean-M

@jmcollin78

This comment has been minimized.

jmcollin78 commented Feb 5, 2016

For those who have same kinds of problems using Nginx here is a workaround:

location ~ (/app/kibana|/bundles/|/kibana4|/status|/plugins) {
        proxy_pass http://localhost:5601;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $host;
        rewrite /kibana4/(.*)$ /$1 break;
    }

It's awfull because of dependencies introducted between RPX and Kibana but it works while waiting for the parameter server.basePath to behave like expected

@LudwigHoff

This comment has been minimized.

LudwigHoff commented Feb 11, 2016

+1

1 similar comment
@thomasfischl

This comment has been minimized.

thomasfischl commented Feb 24, 2016

+1

@pkraeutli

This comment has been minimized.

pkraeutli commented Feb 29, 2016

I someone has a workaround for IIS (reverse proxy) I'd be very interested.

@ovanekem

This comment has been minimized.

ovanekem commented May 25, 2016

This is what I've done with Apache configured as a reverse proxy:

    ProxyPass /kibana http://myserver:5601/
    ProxyPassReverse /kibana http://myserver:5601/
    ProxyPass /app/kibana http://myserver:5601/app/kibana
    ProxyPassReverse /app/kibana http://myserver:5601/app/kibana
    ProxyPass /bundles http://myserver:5601/bundles
    ProxyPassReverse /bundles http://myserver:5601/bundles
    ProxyPass /elasticsearch http://myserver:5601/elasticsearch
    ProxyPassReverse /elasticsearch http://myserver:5601/elasticsearch

With this you can log into kibana using https://your_host/kibana and then all calls are (seem ;-)) correctly forwarded. Of course you cannot have another application on your host on the following URL's: /kibana, /bundles, /elasticsearch and /app/kibana. I'll test a bit more in the coming days to make sure there's no missing URI.

@sammerry

This comment has been minimized.

sammerry commented Aug 22, 2016

+1

tardyp added a commit to tardyp/buildbot-infra that referenced this issue Sep 2, 2016

@yannouchou

This comment has been minimized.

yannouchou commented May 11, 2017

+1 Obviously...
domains are a valuable thing, we can't keep needing 1 domain for every tool... Also I would not expect this to be too difficult to implement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment