# Kibana and Nginx in subpath

**URL:** <https://discuss.elastic.co/t/kibana-and-nginx-in-subpath/90280>\
**Category:** Kibana\
**Created:** [June 21, 2017, 12:07pm UTC](https://discuss.elastic.co/t/kibana-and-nginx-in-subpath/90280 "2017-06-21T12:07:28Z")\
**Posts on this page:** 1\
**Showing post:** 5

<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:** [June 23, 2017, 5:45pm UTC](https://discuss.elastic.co/t/kibana-and-nginx-in-subpath/90280/5 "2017-06-23T17:45:19Z")

</div>

> Is Kibana really ready to be used behind a reverse proxy who use subpath instead of domain name ?

Absolutely!

Here is a configuration that worked for me:

kibana.yml

```auto
server:
  basePath: "/awesome"
  host: "tim-virtual-machine.local"
  ssl:
    key: "/home/tim/server.key"
    cert: "/home/tim/server.crt"

```

nginx.conf

```auto
  # proxy kibana with a /awesome base path
  server {
    listen 5665;
    access_log logs/proxy.access-kbn.log main;
    server_name tim-virtual-machine.local;

    ssl_certificate /home/tim/server.crt;
    ssl_certificate_key /home/tim/server.key;

    ssl on;
    ssl_session_cache builtin:1000 shared:SSL:10m;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
    ssl_prefer_server_ciphers on;

    location /awesome {
      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;

      proxy_pass https://tim-virtual-machine.local:5601/;
      rewrite ^/awesome/(.*)$ /$1 break;
    }
  }

```

Now when I got to [https://tim-virtual-machine.local:5665/awesome](https://tim-virtual-machine.local:5665/awesome), I'm able to access Kibana.

I prefer adding the `rewrite` rule because it makes it explicit that the proxy needs to remove the base path from requests before they hit the Kibana server. There is a simpler, more implicit way to do this by adding slashes in the config appropriately. What I mean is, the following nginx config does the same thing, but the path removal is done automatically by nginx (note that the `location` line now has a slash at the end):

```auto
    location /awesome/ {
      proxy_pass https://tim-virtual-machine.local: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;
    }

```

---

_[View the full topic](https://discuss.elastic.co/t/kibana-and-nginx-in-subpath/90280)._
