# 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:** 1\
**Showing post:** 6

<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;
    }
}
```

---

_[View the full topic](https://discuss.elastic.co/t/kibana-5-4-behind-nginx/98114)._
