# Kibana 5.4 behind Nginx

**URL:** https://discuss.elastic.co/t/kibana-5-4-behind-nginx/98114
**Category:** Kibana
**Created:** [August 23, 2017, 6:11pm UTC](https://discuss.elastic.co/t/kibana-5-4-behind-nginx/98114 "2017-08-23T18:11:49Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![Nikhanj](https://avatars.discourse-cdn.com/v4/letter/n/f4b2a3/32.png) [@Nikhanj](https://discuss.elastic.co/u/Nikhanj)
#### Post date: [August 23, 2017, 6:11pm UTC](https://discuss.elastic.co/t/kibana-5-4-behind-nginx/98114/1 "2017-08-23T18:11:50Z")

</div>

Hello,  
I have researched a lot of posts about configuring Kibana 5 behind Nginx, but I am not able to achieve it. I am trying to set up like this : [http://myhost/kibana](http://myhost/kibana) to work.

I tried this in kibana.conf

location / {  
rewrite ^/kibana/(.\*)$ /$1 break;  
proxy\_pass [http://localhost:5601/;](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;  
}

and also set server.basePath = "/kibana" in kibana.yml file.

But even then, the links on the left sidebar does not show the updated path. Instead of showing [http://myhost/kibana/app/monitoring](http://myhost/kibana/app/monitoring), it still shows [http://myhost/app/monitoring](http://myhost/app/monitoring).  
If I manually access the URL I am able to view but the links on the left sidebar does not get updated.

The links in the JS are not updated. Anyone faced similar issue ?

Thanks,  
Nikhanj

---

<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: [August 23, 2017, 6:44pm UTC](https://discuss.elastic.co/t/kibana-5-4-behind-nginx/98114/2 "2017-08-23T18:44:25Z")

</div>

Hrm, that's strange. I'm no expert in nginx, but that config looks right. Kibana loads, so that's probably fine.

The `server.basePath` setting should be all it takes to get this working. The incorrect links in the app make me thing that the setting isn't being loaded. Did you restart Kibana after you added that setting? And are you sure you're editing the right `kibana.yml` file, or putting it in the right location?

---

<div class="post-metadata">

### Author: ![Nikhanj](https://avatars.discourse-cdn.com/v4/letter/n/f4b2a3/32.png) [@Nikhanj](https://discuss.elastic.co/u/Nikhanj)
#### Post date: [August 23, 2017, 6:49pm UTC](https://discuss.elastic.co/t/kibana-5-4-behind-nginx/98114/3 "2017-08-23T18:49:02Z")

</div>

Yea I was editing the right file and I restarted Kibana. Still the links aren't updated. Also some of the icons for each of the links on left sidebar is gone.

Thanks,  
Nikhanj

---

<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: [August 23, 2017, 8:02pm UTC](https://discuss.elastic.co/t/kibana-5-4-behind-nginx/98114/4 "2017-08-23T20:02:44Z")

</div>

> [@Nikhanj](#):
>
> Also some of the icons for each of the links on left sidebar is gone.

Can you inspect them and see what the URLs it's trying to load for those images are? That's pretty weird, and could be an indication that there's a routing issue.

---

<div class="post-metadata">

### Author: ![Nikhanj](https://avatars.discourse-cdn.com/v4/letter/n/f4b2a3/32.png) [@Nikhanj](https://discuss.elastic.co/u/Nikhanj)
#### Post date: [August 24, 2017, 6:07pm UTC](https://discuss.elastic.co/t/kibana-5-4-behind-nginx/98114/5 "2017-08-24T18:07:02Z")

</div>

![1](https://us1.discourse-cdn.com/elastic/original/3X/c/2/c2a713ec532765e3ff551a113dfb0a21df9ed744.JPG)

PFA for the inspected page. On the left there are no icons for the links and also the anchor href is not updated to [https://myhost/kibana/app/kibana#/discover](https://myhost/kibana/app/kibana#/discover)

Any ideas ?

Thanks,  
Nikhanj

---

<div class="post-metadata">

### Author: ![bryanm](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@bryanm](https://discuss.elastic.co/u/bryanm)
#### Post date: [August 25, 2017, 8:24pm UTC](https://discuss.elastic.co/t/kibana-5-4-behind-nginx/98114/6 "2017-08-25T20:24:44Z")

</div>

I just happened to get this working after quite a lot of effort so here it is to save other's some time. I haven't tested it extensively so ymmv. Make sure to set your server.basepath to /kibana in the kibana config.

```
# Exact URI match to load the base kibana page without a redirect
location = /kibana {
    proxy_pass http://127.0.0.1:5601/app/kibana;
    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;
}
# Catch for all other kibana resources. Removes proxy URI before passing on
location /kibana {
    rewrite ^/kibana/(.*)$ /$1 break;
    proxy_pass http://127.0.0.1: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;
}
# Catch for a stray kibana call that doesn't properly prepend the proxy URI
location /api {
    if ($http_referer ~ "^.*/kibana") {
        proxy_pass http://127.0.0.1:5601;
    }
}
```

---

<div class="post-metadata">

### Author: ![tsullivan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tsullivan/32/31077_2.png) [@tsullivan](https://discuss.elastic.co/u/tsullivan)
#### Post date: [August 28, 2017, 6:40pm UTC](https://discuss.elastic.co/t/kibana-5-4-behind-nginx/98114/7 "2017-08-28T18:40:15Z")

</div>

Nikhanj, if you are still having that issue, make sure that when you restarted Kibana, the front-end code bundles were reoptimized successfully. Setting a `server.basePath` in config requires the front-end code to be reoptimized.

Try removing your `optimize/bundles` directory in the Kibana install path, and restarting Kibana. As it starts up, check that you aren't running into any file permission problems.

---

<div class="post-metadata">

### Author: ![Nikhanj](https://avatars.discourse-cdn.com/v4/letter/n/f4b2a3/32.png) [@Nikhanj](https://discuss.elastic.co/u/Nikhanj)
#### Post date: [August 28, 2017, 7:17pm UTC](https://discuss.elastic.co/t/kibana-5-4-behind-nginx/98114/8 "2017-08-28T19:17:18Z")

</div>

Thanks Sullivan. Your fix worked. I deleted the files under optimize/bundles and restarted.

Thanks much !!  
-Nikhanj

---

<div class="post-metadata">

### Author: ![Nikhanj](https://avatars.discourse-cdn.com/v4/letter/n/f4b2a3/32.png) [@Nikhanj](https://discuss.elastic.co/u/Nikhanj)
#### Post date: [August 28, 2017, 7:18pm UTC](https://discuss.elastic.co/t/kibana-5-4-behind-nginx/98114/9 "2017-08-28T19:18:37Z")

</div>

Hi Bryanm,  
Thanks for your config. I used a smaller version of it  
location / {  
rewrite ^/kibana/(.\*)$ /$1 break;  
proxy\_pass [http://localhost:5601/;](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;  
}

and followed sullivan's method and it worked.

Thanks,  
Nikhanj

---

<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: [September 25, 2017, 7:18pm UTC](https://discuss.elastic.co/t/kibana-5-4-behind-nginx/98114/10 "2017-09-25T19:18:40Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
