Kibana behind NGINX

Hello,
i'm using kibana behind reverse proxy along side with a node API application that uses elasticsearch.
This is config of NGINX :

     location / {
            auth_basic "Restricted Access";
            auth_basic_user_file /etc/nginx/htpasswd.users;
            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;
       }
location /api/ {
             proxy_pass http://localhost:4000/;
             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;
       }

with this configuration, kibana starts but shows blank pages when hitting Discover, visualize and others
image
when i remove the /api part of nginx config, things return to normal
i don't know if it's a problem related to kibana or nginx configuration ??

Hey @med_barka, Kibana makes various request to /api/* so if you're diverting all requests that match that prefix to your other application, Kibana won't work properly.

Thanks for your response.. so it's not possible to config it that way? Is there any solution?

I changed kibana access to be ' /kibana' with '/api/' and it works... so it can't be done when it's based at '/' ?

Is there any solution?

The safest solution is to have kibana being a base-path like /kibana and your custom api at /api so there isn't any possibility of the proxy diverting requests which are intended to kibana to your custom API.

Theoretically, you could choose something more obscure like /super-awesome-api and the likelihood that it'd intercept the wrong requests goes down.

I'll give it a try... thank you Brandon

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