NGINX reverse proxy problem

Hi,

I'm having some difficulties with setting up a reverse proxy in combination with iframes. When using / as the location browsing to sub.mydomain.com, the proxy is working but the root location is skipped and I get the normal Kibana dashboard without any of my own html.

When I change location to something like /app/kibana my own html shows but the iframe isn't loaded.

Is there any way to get this to work?

ServerA: Running NGINX and Kibana
ServerB: Running Elasticsearch, only allows access from ServerA IP

NGINX.conf

server {
        listen 80;
        listen [::]:80;

        root /var/www/sub.mydomain.com/html;
        index index.html index.htm index.nginx-debian.html;

        server_name sub.mydomain.com;

        location / {
                proxy_set_header Host $host;
                proxy_pass http://localhost:5601/;
        }
}

HTML snippet

            <div id="container">
                  <iframe name="frame" iframe id="frame" src="http://localhost:5601/app/kibana#/dashboards"></iframe>
            </div>

Hey @Sjaak01,

You might have better luck after configuring a base path for Kibana via server.basePath, described here: https://www.elastic.co/guide/en/kibana/current/settings.html

Once the base path is set, you can set your location to the configured base path, and have nginx proxy the request from there. Note your iframe src would also change to include this base path.

1 Like

Thanks.

I tried that before but turns out I didn't remove the localhost part from my iframe src so that caused Kibana to not load.

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