# Reverse proxy Kibana

**URL:** https://discuss.elastic.co/t/reverse-proxy-kibana/43647
**Category:** Kibana
**Created:** [March 7, 2016, 11:52am UTC](https://discuss.elastic.co/t/reverse-proxy-kibana/43647 "2016-03-07T11:52:27Z")
**Posts on this page:** 16
**Page:** 1

<div class="post-metadata">

### Author: ![abhijitdeka11](https://avatars.discourse-cdn.com/v4/letter/a/c5a1d2/32.png) [@abhijitdeka11](https://discuss.elastic.co/u/abhijitdeka11)
#### Post date: [March 7, 2016, 11:52am UTC](https://discuss.elastic.co/t/reverse-proxy-kibana/43647/1 "2016-03-07T11:52:27Z")

</div>

Hi,  
I am embedding kibana inside my application which has other features also.I use reverse proxy to do this mapping.  
So,whenever I hit this URL /analytics/\* all calls are redirected to kibana server.

Now with the new upgrade all my reverse proxy code is broken. It seems that the URL's returned are not relative anymore.Earlier i used to get subsequent URL's like  
[http://host/](http://host/) **analytics** /bundles/commons.style.css?v=9689 but now the relative URL is gone and I am getting  
only [http://host/bundles/commons.style.css?v=9689](http://host/bundles/commons.style.css?v=9689).

This is my nginx config on kibana machine [link](http://pastebin.com/155fyuRq). Please let me know if there is any work around for me.I tried URL.basepath property but I am not sure why I am not able to make that work.

---

<div class="post-metadata">

### Author: ![Joe\_Fleming](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joe_fleming/32/3561_2.png) [@Joe\_Fleming](https://discuss.elastic.co/u/Joe_Fleming)
#### Post date: [March 8, 2016, 12:03am UTC](https://discuss.elastic.co/t/reverse-proxy-kibana/43647/2 "2016-03-08T00:03:29Z")

</div>

Have you added `/analytics` to the `basePath` in your kibana.yml file.

If so, it sounds like this happened when upgrading Kibana versions. What version where you running before when it worked, and what version are you trying to run now?

---

<div class="post-metadata">

### Author: ![abhijitdeka11](https://avatars.discourse-cdn.com/v4/letter/a/c5a1d2/32.png) [@abhijitdeka11](https://discuss.elastic.co/u/abhijitdeka11)
#### Post date: [March 8, 2016, 5:29am UTC](https://discuss.elastic.co/t/reverse-proxy-kibana/43647/3 "2016-03-08T05:29:09Z")

</div>

Yes I have added this in the Kibana.yml file. Yes, this happened because of the upgrade.I was on Kibana 4.1 and now upgraded to Kibana 4.4 .I can see this issue [here](https://github.com/elastic/kibana/issues/5171) and [here](https://github.com/elastic/kibana/issues/5230) but these are already closed. But i can still reproduce them at my end.How do I proceed?

---

<div class="post-metadata">

### Author: ![Joe\_Fleming](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joe_fleming/32/3561_2.png) [@Joe\_Fleming](https://discuss.elastic.co/u/Joe_Fleming)
#### Post date: [March 8, 2016, 5:55pm UTC](https://discuss.elastic.co/t/reverse-proxy-kibana/43647/4 "2016-03-08T17:55:45Z")

</div>

Both of those issues target older versions of Kibana, and the fixes are definitely in 4.4.x. Part of our development process includes running Kibana behind a reverse proxy, which we do explicitly to make sure we don't break the basePath stuff again (we also use SSL for the same reason).

One cause I can think of is that either the setting in the yml is somehow wrong (misspelled or something perhaps), but this _should_ cause Kibana to fatal on startup. The other thing that comes to mind is maybe the file isn't being used (perhaps it's in the wrong path or has the wrong permissions or something?).

Can you try changing another setting to ensure that it's being used? A good candidate would be to change the `elasticsearch.url` setting to something invalid, like using the wrong hostname and/or port. Then, restart Kibana and ensure that it fails to connect to your ES instance. Let me know if you can do that, and how it goes.

---

<div class="post-metadata">

### Author: ![abhijitdeka11](https://avatars.discourse-cdn.com/v4/letter/a/c5a1d2/32.png) [@abhijitdeka11](https://discuss.elastic.co/u/abhijitdeka11)
#### Post date: [March 9, 2016, 3:29am UTC](https://discuss.elastic.co/t/reverse-proxy-kibana/43647/5 "2016-03-09T03:29:23Z")

</div>

Ok this is what I did.  
1.Downloaded and started ES2.2.0  
2.Indexed a document  
3. Downloaded the latest Kibana4.4.1 zip via the downloads page.  
4.Extracted and started Kibana.  
6.Go to [http://localhost:5601](http://localhost:5601) I can see the indexed doc in the discover tab after I configure the index.

All working fine for me till now.Now the next steps  
6. Un-commented the entry and added  
server.basepath:"analytics"

7.Restart kibana.  
8.[http://localhost:5601](http://localhost:5601) redirects me to [http://localhost](http://localhost):analytics/app/kibana and a 404 error throws up.  
9.[http://localhost:5601/app/kibana](http://localhost:5601/app/kibana) tries to load other resources from /analytics/bundles and hangs since it's not available.

What is the expected behavior here?Where should I see the kibana homepage now?  
I think this is pretty easy to reproduce.

---

<div class="post-metadata">

### Author: ![Bargs](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bargs/32/5429_2.png) [@Bargs](https://discuss.elastic.co/u/Bargs)
#### Post date: [March 9, 2016, 9:22pm UTC](https://discuss.elastic.co/t/reverse-proxy-kibana/43647/6 "2016-03-09T21:22:27Z")

</div>

server.basepath should be set to `/analytics`, note the slash that's included. Your nginx config then needs to listen for requests to localhost/analytics and pass them to kibana _without_ the /analytics

---

<div class="post-metadata">

### Author: ![abhijitdeka11](https://avatars.discourse-cdn.com/v4/letter/a/c5a1d2/32.png) [@abhijitdeka11](https://discuss.elastic.co/u/abhijitdeka11)
#### Post date: [March 10, 2016, 5:17am UTC](https://discuss.elastic.co/t/reverse-proxy-kibana/43647/7 "2016-03-10T05:17:25Z")

</div>

Thanks @Bargs . If it's not too much trouble for you can you please share your config file. A sample should help me.  
I was trying to find an example but couldn't find one.

---

<div class="post-metadata">

### Author: ![abhijitdeka11](https://avatars.discourse-cdn.com/v4/letter/a/c5a1d2/32.png) [@abhijitdeka11](https://discuss.elastic.co/u/abhijitdeka11)
#### Post date: [March 10, 2016, 5:36am UTC](https://discuss.elastic.co/t/reverse-proxy-kibana/43647/8 "2016-03-10T05:36:11Z")

</div>

@Bargs I tried what you mentioned here. So, redirecting from /ananlytics to localhot:5601 is working fine for me.  
The issue is with Kibana. As I mentioned localhost:5601 redirects me to localhost:5601/analytics/app/kibana and it's throwing 404 error.

Kibana running on 5601 is not accessible anymore.

---

<div class="post-metadata">

### Author: ![Bargs](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bargs/32/5429_2.png) [@Bargs](https://discuss.elastic.co/u/Bargs)
#### Post date: [March 10, 2016, 3:03pm UTC](https://discuss.elastic.co/t/reverse-proxy-kibana/43647/9 "2016-03-10T15:03:51Z")

</div>

I'm not sure I understand exactly.

Are you trying to access kibana directly?

Or are you saying that nginx is proxying from localhost:80/analytics to localhost:5601, and kibana is returning a redirect to nginx for localhost:5601/analytics/app/kibana?

---

<div class="post-metadata">

### Author: ![Joe\_Fleming](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joe_fleming/32/3561_2.png) [@Joe\_Fleming](https://discuss.elastic.co/u/Joe_Fleming)
#### Post date: [March 10, 2016, 5:34pm UTC](https://discuss.elastic.co/t/reverse-proxy-kibana/43647/10 "2016-03-10T17:34:26Z")

</div>

> [http://localhost:5601](http://localhost:5601) redirects me to [http://localhost](http://localhost):analytics/app/kibana and a 404 error throws up

That's normal - when you set the basePath, Kibana will 301 all requests and re-write all asset URL paths to include your basePath prefix. You can no longer just hit localhost:5601, because Kibana doesn't actually this is expected. Once you specify a basePath, you need to actually observe that path, via your reverse proxy.

I did just set this up, and one catch here is that you won't be auto-redirected to `/app/kibana` from the proxy path (which seems like a bug, honestly). But, according to the nginx config you posted earlier, the following url should work, assuming you have running on the machine and running without ssl on port 5601: [https://10.6.204.104/kibana4/app/kibana](https://10.6.204.104/kibana4/app/kibana)

---

<div class="post-metadata">

### Author: ![abhijitdeka11](https://avatars.discourse-cdn.com/v4/letter/a/c5a1d2/32.png) [@abhijitdeka11](https://discuss.elastic.co/u/abhijitdeka11)
#### Post date: [March 11, 2016, 5:54am UTC](https://discuss.elastic.co/t/reverse-proxy-kibana/43647/11 "2016-03-11T05:54:32Z")

</div>

@Bargs Sorry if I am not clear to you. I am trying to hit the URL from all sort of combinations. I think posting my configurations will make this more clear.  
Here is my kibana.yml file configuration for base path

server.basePath: "/analytics"

Here is my corresponding [nginx.config](http://pastebin.com/VxgaW7w1)

Can you tell me is there anything wrong with my configuration?  
I am trying to hit all sort of combinations in the URL.But nothing is working for me.

---

<div class="post-metadata">

### Author: ![abhijitdeka11](https://avatars.discourse-cdn.com/v4/letter/a/c5a1d2/32.png) [@abhijitdeka11](https://discuss.elastic.co/u/abhijitdeka11)
#### Post date: [March 11, 2016, 6:02am UTC](https://discuss.elastic.co/t/reverse-proxy-kibana/43647/12 "2016-03-11T06:02:58Z")

</div>

@Joe_Fleming I am trying to simplify my question. I want to see all kibana in /analytics path.  
Here is my kibana.yml base path

server.basePath: "/analytics"

Here is my corresponding [nginx.config](http://pastebin.com/155fyuRq)

If I am understanding you correctly [https://10.6.204.104/analytics/app/kibana](https://10.6.204.104/analytics/app/kibana) should work.But it is still throwing  
{"statusCode":404,"error":"Not Found"}

Is there anything wrong in my config file?  
Not sure what is the expected URL i am supposed to hit. I tried all sorts of combinations.

---

<div class="post-metadata">

### Author: ![yodog](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yodog/32/4822_2.png) [@yodog](https://discuss.elastic.co/u/yodog)
#### Post date: [August 2, 2016, 7:00pm UTC](https://discuss.elastic.co/t/reverse-proxy-kibana/43647/13 "2016-08-02T19:00:13Z")

</div>

have you tried this?

> [@\[4.3.0 \] how to configure your nginx balancer and apache reverse proxy](https://discuss.elastic.co/t/4-3-0-how-to-configure-your-nginx-balancer-and-apache-reverse-proxy/37351/2):
>
> ok. got it. this is what you need for a fully functional proxy / load balancer answering on [http://my-balancer/kibana/](http://my-balancer/kibana/) #Balancer nginx /etc/nginx/conf.d/elastic-80.server.conf upstream web { server elk-node-01; server elk-node-02; server elk-node-03; keepalive 5; } server { listen 80; location / { proxy\_pass http://web; proxy\_http\_version 1.1; proxy\_set\_header Connection "Keep-Alive"; proxy\_set\_header Proxy-Connection "Keep-Alive…

---

<div class="post-metadata">

### Author: ![deshymers](https://avatars.discourse-cdn.com/v4/letter/d/b9bd4f/32.png) [@deshymers](https://discuss.elastic.co/u/deshymers)
#### Post date: [August 10, 2016, 4:05am UTC](https://discuss.elastic.co/t/reverse-proxy-kibana/43647/14 "2016-08-10T04:05:30Z")

</div>

Hello,

I was having the same issue as what was stated above, and I solved it with help from the following post. [http://serverfault.com/questions/681238/kibana4-nginx-reverse-proxy-using-location-kibana4-not-found-404](http://serverfault.com/questions/681238/kibana4-nginx-reverse-proxy-using-location-kibana4-not-found-404)

This is my nginx snippet for Kibana,

```
location ~ ^/kibana/(.*)$ {
        rewrite /kibana/(.*) /$1 break;
        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;
        proxy_cache_bypass $http_upgrade;
    }

```

A single note on the above snippet, proxy\_pass passes the entire path with the request, and we dont want to pass along the "/kibana" so we need to remove it with a rewrite! and that what is causing the 404.

I also had to set my basepath in kibana to "/kibana".

---

<div class="post-metadata">

### Author: ![abhijitdeka11](https://avatars.discourse-cdn.com/v4/letter/a/c5a1d2/32.png) [@abhijitdeka11](https://discuss.elastic.co/u/abhijitdeka11)
#### Post date: [August 10, 2016, 4:19am UTC](https://discuss.elastic.co/t/reverse-proxy-kibana/43647/15 "2016-08-10T04:19:19Z")

</div>

Thanks Guys. I was able to solve it long back. The key was to consume the server.basepath url on your [request.It](http://request.It) should be documented somewhere properly.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [July 6, 2017, 1:41pm UTC](https://discuss.elastic.co/t/reverse-proxy-kibana/43647/16 "2017-07-06T13:41:28Z")

</div>


