Issues with loading Kibana Behind GCP LoadBalancer and nginx reverse proxy

Hello --

I am attempting to load our kibana site behind a GCP load balancer and a nginx reverse proxy but running into issues. Essentially, we would like to rewrite our site to append the /kibana path at the end. For example:

http://example.com/kibana

There are a few things we are doing on the GCP load balancer that should be worth mentioning. First off, we have a SSL certificate on the GCP LB that is creating a secure SSL connection to our site 'example.com'. When requests come in on port 80, they are re-written to 443. I am not sure if this affects the configuration of what I need in the nginx / kibana configuration but figured it was worth mentioning.

The GCP Load Balancer backend for our kibana server is sending the requests to port 80, not 443. So LB receives 443 and sends it to port 80 on the backend.

Secondly, if I test this site by directly hitting the GCP instance and bypassing the GCP LB the site loads fine. For example 'http://instance-ip/kibana'.

Below is the configuration for my website in nginx:

server {
listen 80;

server_name $hostname example.com;

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

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

}
}

I have also updated the kibana.yml file to include the following:
server.basePath: "/kibana"

When I attempt to load the page via the GCP LB I get the following error message off of my browsers dev tools:
'Failed to load resource: the server responded with a status of 404 ()'

What else is interesting is the source path for the site seems to be incorrect, it looks like this:

example.com ->
kibana/app ->
kibana

Let me know what other information is needed. I am very new to ELK (and to be honest 'nginx') so this may be a simple fix.

Thank you!

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