Kibana and Nginx in subpath

I've tried without success several configurations to get Kibana 4.5.4 to work in https://myhost/kibana

Nginx configuration 1:

server {

    listen 80;
    # SSL configuration

    listen 443 ssl http2 default_server;
    listen [::]:443 ssl http2 default_server;
    include snippets/self-signed.conf;
    include snippets/ssl-params.conf;

    auth_basic "Restricted Access";
    auth_basic_user_file /etc/nginx/htpasswd.users;

     location ~ (/elasticsearch/|/app/|/bundles/|/kibana|/status|/plugins) {
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            proxy_set_header Host $host;

            proxy_pass http://localhost:5601;
        }
}

with server.basePath: "/kibana", I get 502 Bad Gateway. Without setting the base path, I get:

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

Using this approach, I get

Courier Fetch Error: unhandled courier request error: Not Found
Version: 4.5.4
Build: 10000
Error: unhandled courier request error: Not Found
handleError@https://myhost/bundles/kibana.bundle.js?v=10000:80950:32
handleFailure@https://myhost/bundles/kibana.bundle.js?v=10000:80870:34
https://myhost/bundles/kibana.bundle.js?v=10000:80764:31
forEach@[native code]
https://myhost/bundles/kibana.bundle.js?v=10000:80762:26
processQueue@https://myhost/bundles/commons.bundle.js?v=10000:42404:31
https://myhost/bundles/commons.bundle.js?v=10000:42420:40
$digest@https://myhost/bundles/commons.bundle.js?v=10000:43459:37
$apply@https://myhost/bundles/commons.bundle.js?v=10000:43756:32
done@https://myhost/bundles/commons.bundle.js?v=10000:38205:54
completeRequest@https://myhost/bundles/commons.bundle.js?v=10000:38403:16
requestLoaded@https://myhost/bundles/commons.bundle.js?v=10000:38344:25
1 Like

There is another topic with a similar problem here: Reverse proxy Kibana

I have already tried that. You can see it in the first Nginx configuration I posted here.

I have the same behavior with kibana 5.4.
I can't figure out how to configure Nginx to work as reverse proxy.
Is Kibana really ready to be used behind a reverse proxy who use subpath instead of domain name ?

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

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

nginx.conf

  # 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, 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):

    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;
    }
5 Likes

I can't get it work with this config:

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

Yong_Zhang, can you share the server.basePath setting that you have in your kibana.yml file, as well as your proxy configuration?

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