Kibana 5.4 behind Nginx


(Nikhanj R) #1

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 to work.

I tried this in kibana.conf

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

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, it still shows 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


(Joe Fleming) #2

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?


(Nikhanj R) #3

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


(Joe Fleming) #4

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.


(Nikhanj R) #5

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

Any ideas ?

Thanks,
Nikhanj


#6

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

(Tim Sullivan) #7

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.


(Nikhanj R) #8

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

Thanks much !!
-Nikhanj


(Nikhanj R) #9

Hi Bryanm,
Thanks for your config. I used a smaller version of it
location / {
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;
}

and followed sullivan's method and it worked.

Thanks,
Nikhanj


(system) #10

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