pantsel / konga

More than just another GUI to Kong Admin API
MIT License
4.3k stars 826 forks source link

Make konga work with relative paths #21

Closed bakstad closed 7 years ago

bakstad commented 7 years ago

We run konga on a cluster and at the moment rely on web paths to route traffic to the correct instance.

That means we call a URL like so: http://cluster.example.com/konga-gui/. The problem is that Konga assumes assets are found on the webroot and therefore the frontend is not loaded.

In the logs and HTML this is reflected. Notice all the /vendors.min.css, /frontend.min.js etc.

This was mentioned as a part of #14, but not fully implemented it seems. What I would like is a environment variable KONGA_FRONTEND_WEBROOT (or something more fitting) that will be prepented to all the asset paths.

HTML:


<!DOCTYPE html><html data-ng-app="frontend"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Konga</title><link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet"><link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"><link rel="stylesheet" href="/vendors.min.css"><link rel="stylesheet" href="/frontend.min.css"></head><body data-ng-cloak class="ng-cloak"><div data-ui-view="header"></div><div ng-if="isAuthenticated() && $state.name != 'admin'" class="page-head container-fluid"><div class="container"><h3 class="page-title"><span ng-bind-html="$state.data.prefix" class="page-title-prefix"></span> <span ng-bind-html="$state.data.pageName"></span>&nbsp;<div ng-show="loading" id="spinner" data-spinner="{&quot;radius&quot;: 15,&quot;strokeWidth&quot;:3}" style="display: inline-block"></div></h3><ui-breadcrumbs displayname-property="data.displayName" template-url="/frontend/core/layout/partials/uiBreadcrumbs.tpl.html"></ui-breadcrumbs></div></div><div class="container main-container"><div data-ui-view="content"></div></div><div data-ui-view="footer"></div><script>(function onLoad() {
                var io;

                Object.defineProperty(window, 'io', {
                    get: function get() {
                        return io;
                    },
                    set: function set(value) {
                        var sails;

                        io = value;

                        Object.defineProperty(io, 'sails', {
                            get: function get() {
                                return sails;
                            },
                            set: function set(value) {
                                sails = value;

                                sails.url = 'http://cluster.example.com/konga-backend';
                            }
                        });
                    }
                });

                //Logging
                window.enableLogs = 'false'

            })();</script><script src="/vendors.min.js"></script><script src="/frontend.min.js"></script></body></html>
pantsel commented 7 years ago

Check out the dev branch. I forgot to implement the changes in dist logic.

It should work now.

bakstad commented 7 years ago

Could you please set up building of branches on dockerhub? That way I can test it without building my self

pantsel commented 7 years ago

I'll do that some time later today

bakstad commented 7 years ago

When using the docker image locally I have problems using the plugins tab, dashboard and node info. Seem ot be getting 404 og 503s. Consumers and APIs work though.

Any ideas?

GET http://localhost:9999/kong/plugins 503 (Service Unavailable) GET http://localhost:9999/kong/info 404 (Not Found)

started like so:

ocker run -it -p 3000:3000 -p 9999:1338 -e KONGA_BACKEND_URL=http://localhost:9999 --name konga pantsel/konga
pantsel commented 7 years ago

What version of Kong are you using? Is it 0.9.x?

bakstad commented 7 years ago

We are actually stuck on 0.8.x, that might be the problem.

pantsel commented 7 years ago

At what ip:port is Kong's admin api exposed?

Are you using a container for Kong? In that case you will need to add a link --link kong:kong in your run command and the node you'll need to setup in Konga's settings will be http://kong:8001.

bakstad commented 7 years ago

I'm not running Kong locally, but using Konga locally. So i'm pointing to kong on an external address.

pantsel commented 7 years ago

The fact that some endpoints do work and some don't, makes me think that the issue is maybe related to Kong's version. I haven't tried Konga on versions older than 0.9.x. I will have to test it and get back to you.

bakstad commented 7 years ago

Things seem to work much better with 0.9.x, so don't worry about it.

BUt it would be nice if you could get automated build of branches.