I am new to kong, Konga and Docker stacks. I have build a docker-compose file which will run kong and konga. In the Konga service I have exposed post 1337 and it is working without any issue. I can log in to Konga, connect it to kong and preform operations.
I had what I thought was a clever idea and I decided to expose Konga via Kong. I just added an API
(part of the raw view)
"created_at": 1515856518917,
"strip_uri": true,
"id": "fb66facc-78d3-4b97-a577-2f0a006c8b45",
"name": "konga",
"http_if_terminated": false,
"https_only": false,
"upstream_url": "http://konga:1337",
"uris": [
"/konga"
],
"preserve_host": false,
"upstream_connect_timeout": 60000,
I can now go to http://mypublicdockerstack:80/konga/ I get the kong log in. I have been able to do this both through http and https.
However - I have a rather confusing issue. If I go to connections and get konga to connect to kong I get the message "Oh snap! Can't connect to http://kong:8001" This works for both http and https.
If I switch to the directly exposed kong port it works without a problem.
I can't understand why the method I use to connect to konga is affecting the connection between konga and kong. Again I am a beginner so I am probably missing something simple.
The docker file I am using is:
````
version: "3.1"
secrets:
webservices_hostname:
external: true
webservices_cert:
external: true
webservices_key:
external: true
services:
kong-database:
image: postgres:9.4
deploy:
restart_policy:
condition: any
environment:
- POSTGRES_USER=kong
- POSTGRES_DB=kong
healthcheck:
test: ["CMD", "pg_isready", "-U", "postgres"]
interval: 10s
timeout: 5s
retries: 5
kong-migration:
image: kong
deploy:
restart_policy:
condition: on-failure
environment:
- KONG_DATABASE=postgres
- KONG_PG_HOST=kong-database
command: kong migrations up
deploy:
restart_policy:
condition: on-failure
kong:
image: kong
deploy:
restart_policy:
condition: any
secrets:
- webservices_cert
- webservices_key
environment:
- KONG_DATABASE=postgres
- KONG_PG_HOST=kong-database
- KONG_PG_DATABASE=kong
- KONG_SSL_CERT=/run/secrets/webservices_cert
- KONG_SSL_CERT_KEY=/run/secrets/webservices_key
ports:
- 80:8000
- 443:8443
healthcheck:
test: ["CMD-SHELL", "curl -I -s -L http://127.0.0.1:8000 || exit 1"]
interval: 5s
retries: 10
restart: on-failure
konga:
image: pantsel/konga
deploy:
restart_policy:
condition: on-failure
ports:
- 1337:1337
kong-addapis-konga:
image: byrnedo/alpine-curl
deploy:
restart_policy:
condition: on-failure
command: "-i -X POST
--url http://kong:8001/apis/
--data 'name=flaskapp'
--data 'uris=/flaskapp'
--data 'upstream_url=http://flaskapp:80'
--data 'https_only=true'
"
````
The command I use to start the docker stack is:
docker stack deploy --compose-file ./docker-compose.yml webservices
Thanks in advance for any advice.
I am not sure if this was the correct place to ask this so I have posted here
https://stackoverflow.com/questions/48262114/use-kong-to-expose-konga
Hi @rmetcalf9 ,
have you tried adding a link to Kong in Konga's config block?
Something like this
https://gist.github.com/pantsel/5e25b77fbb940498053fdcb589ca96fd
Hi,
I have added the link as you suggested in the docker compose file. This did not change the situation.
The konga container is able to connect to the kong container - this is proved by the fact that the port 1337 method is working without a problem. There is just some difference when I am connected via kong.
@rmetcalf9 , try setting the internal Kong's container ip instead of the host name in Konga's connection and see what happens.
ex. from the UI
instead of http://kong:8001
try
Kong url : http://10.12.xx.x:8001
I will test your compose file when i get some time.
Do you know how I can find what the internal kong ip is?
$ docker inspect your-kong-container-id
I'm not sure you want to expose konga via kong. If something is wrong in kong configuration, you could lose access to konga (that could be use to fix kong configuration otherwise).
@rparpa , that's a valid point.
Could it be something to do with the trailing /?
http://mypublicdockerstack:1337 - gives me a good html page
http://mypublicdockerstack:1337/ - gives me a good html page
http://mypublicdockerstack:80/konga - gives me a bad html page saying "Neat! Your account is activated."
http://mypublicdockerstack:80/konga/ - gives me a good html page
There is something different here. The Neat! Your account is activated message is strange.
When I added the api to konga I put no slash on the Uri's section and I also had no slash on the end of the upstream uris section either. I have experimented with adding slashes on the end but it makes no difference.
Also I noticed that the one through konga has no faveicon image but the one where the port is directly exposed does. This seems weird. I have a feeling I have added the api incorrectly.
I found the IP and tried it. Same result
Oh snap! Can't connect to http://10.0.0.13:8001
It works via the exposed port (1337), but not via kong
I have dug a little deeper and I believe I have found the problem. Using chromes debug mode network tab I can see the actual request that is failing: (This is the https method)
https://mypublicdockerstack:443/kong?connection_id=1
This is returning 404 - {"message":"no API found with those values"}
I can instantly see why this is wrong. Konga is sending the request to the wrong place - it should go to
https://mypublicdockerstack:443/konga/kong?connection_id=1
Other parts of Konga seem to work when hosted in a path that is not the root. I believe this is a bug in Konga.
I can't search github for "$http.get('/" :(
but I did search the code for connection_id
I got two hits that show the issue:
assets/js/app/dashboard/02_dashboard-controller.js line 221:
`` $http.get('/kong',{
and
assets/js/app/connections/connections-controller.js line 213:
`` $http.get('/kong',{
In all other cases $http.get doesn't start with a slash.
It's possible this would be a simple fix.
I have checked after commit 8cf04ba and it is now working.
Thanks for the fix
Neat! Your account is activated. 我也出现这个问题了
I my case the problem was different. I was using docker to run Kong, Konga and Postgresql on a separate network on docker called kong-net. Each of these docker containers exposed ports on host machine's 127.0.0.1. I could access Kong's service page at http://127.0.0.1:8001/. However, putting this URL in Konga's GUI configuration page yielded the "Oops.." error.
I then realized a foolish mistake. From the container's perspective 127.0.0.1 would point to itself! So I ran sudo docker network inspect kong-net to get the IP of the Kong server on kong-net network and used that in Konga's config page.
I my case the problem was different. I was using docker to run Kong, Konga and Postgresql on a separate network on docker called
kong-net. Each of these docker containers exposed ports on host machine's127.0.0.1. I could access Kong's service page at http://127.0.0.1:8001/. However, putting this URL in Konga's GUI configuration page yielded the "Oops.." error.I then realized a foolish mistake. From the container's perspective
127.0.0.1would point to itself! So I ransudo docker network inspect kong-netto get the IP of the Kong server onkong-netnetwork and used that in Konga's config page.
Thanks. You really saved my day.
I my case the problem was different. I was using docker to run Kong, Konga and Postgresql on a separate network on docker called
kong-net. Each of these docker containers exposed ports on host machine's127.0.0.1. I could access Kong's service page at http://127.0.0.1:8001/. However, putting this URL in Konga's GUI configuration page yielded the "Oops.." error.I then realized a foolish mistake. From the container's perspective
127.0.0.1would point to itself! So I ransudo docker network inspect kong-netto get the IP of the Kong server onkong-netnetwork and used that in Konga's config page.
Thanks, this solved my issue as well
docker network inspect kong-net
Thanks a lot PriyankPa.
Most helpful comment
I my case the problem was different. I was using docker to run Kong, Konga and Postgresql on a separate network on docker called
kong-net. Each of these docker containers exposed ports on host machine's127.0.0.1. I could access Kong's service page at http://127.0.0.1:8001/. However, putting this URL in Konga's GUI configuration page yielded the "Oops.." error.I then realized a foolish mistake. From the container's perspective
127.0.0.1would point to itself! So I ransudo docker network inspect kong-netto get the IP of the Kong server onkong-netnetwork and used that in Konga's config page.