有没有一种方法可以在不使用curl的情况下在Kong中添加API端点?我使用 docker-compose 在 docker 容器中启动并运行 Kong,并且我希望能够在容器启动时传递一个配置文件(或您拥有的文件),该文件概述了我想要设置的端点。这可能吗?这是我找到的最接近的解决方案:http://blog.toast38coza.me/kong-up-and-running-part-2-defining-our-api-gateway-with-ansible/
I have a Kong API Gateway container and a postgres container and I need to check whether postgres has started up and ready from the Kong container before running the migrations. I was thinking of installing the postgres client utilities into a custom image based on the official Kong image using RUN yum install postgresql -y && yum clean all in my Dockerfile and using either psql or pg_isready to achieve this. I've created a postgres user called polling with …
我正在构建一个 Lua 库(实际上是一个内部 kong 插件),这是我第一次使用 Lua - 更不用说用它编写生产代码了。
我已经把它变成了luarock。据我所知,它rockspec允许我指定其他库作为依赖项。但似乎不存在开发依赖性的概念。例如,我的测试、模拟等所需的库......我宁愿不让它们成为实际依赖项列表的一部分。
我已经将我的开发依赖项保留在依赖项列表中,但在 git 推送之前将它们注释掉。在生产 Lua 项目中通常如何解决这个问题?管理这些依赖关系的推荐方法是什么?
目前,我们有多个不在网关后面的 API。公开公开的 API 使用 OpenID Connect 进行身份验证和声明授权。某些 API 仅供内部使用,并且受防火墙保护网络安全。
我们计划在我们的 API 之前设置 Kong Gateway Enterprise。我们应该能够在网关处集中来自公共客户端的令牌验证。我们也可以集中一些基本授权(例如范围)。上游 API 中可能仍需要发生一些逻辑。因此,这些 API 仍然需要了解调用者(客户端和用户)的上下文。
理想情况下,我们希望能够拥有可以公开公开并在内部调用的 API,以避免重复逻辑。我想了解一些安全的方法来让 Kong 实现这一点。我仍然不清楚如何设置网关后面的系统。
我的一些问题是:
其他一些可能有用的注释:
我正在遵循此指南:
http://lua-programming.blogspot.co.uk/
我是需要创建API的那一部分。我以前使用过kong,并创建了一个脚本来制作api。问题是我无法创建API。我的脚本实际上是一个没有插件的准系统api(想先创建一个api):
curl -X POST --url http://localhost:8001/apis/ --data 'name=mock' --data 'upstream_url=https://mockbin.com' --data 'request_host=mockbin.com';
每当我运行此命令时,都会出现curl: (52) Empty reply from server错误,但是当我执行该命令时curl -X GET --url http://localhost:8001/apis,它会告诉我当前有多少个api(为0),因此服务器肯定没有问题,对吗?
Ive在本地安装了cassandra和kong。有任何想法吗?
Kong使用Cassandra或Postgres.Cassandra知道用于编写繁重的应用程序.我没有看到Kong api网关那么重写,也没有一个表使用Cassandra重要的功能分区键之一.我怀疑是为什么Cassandra用于Kong,有什么特别的原因吗?我们不能使用RDBMS来实现这一点.
我们目前正在为我们的微服务分析 API 网关,Kong 是可能的候选者之一。我们发现 Kong 支持多种身份验证插件,但所有插件都基于存储在 Kong 数据库本身中的用户。我们需要将此责任委托给我们的自定义身份验证 HTTP 服务,并且不想将这些用户添加到 API 网关数据库中。
我已将Docker Kong 映像升级到版本 0.14.0,它停止响应来自容器外部的连接:
$ curl 127.0.0.1:8001 --trace-ascii dump.txt
== Info: Rebuilt URL to: 127.0.0.1:8001/
== Info: Trying 127.0.0.1...
== Info: Connected to 127.0.0.1 (127.0.0.1) port 8001 (#0)
=> Send header, 78 bytes (0x4e)
0000: GET / HTTP/1.1
0010: Host: 127.0.0.1:8001
0026: User-Agent: curl/7.47.0
003f: Accept: */*
004c:
== Info: Recv failure: Connection reset by peer
== Info: Closing connection 0
Run Code Online (Sandbox Code Playgroud)
端口映射是
0.0.0.0:8000-8001->8000-8001/tcp, 0.0.0.0:8443-8444->8443-8444/tcp
尝试从容器内部连接时一切正常:
/ # curl 127.0.0.1:8001
{"plugins":{"enabled_in_cluster":[], ...
Run Code Online (Sandbox Code Playgroud)
端口 8000 可从容器外部和内部访问。那会是什么?
我遇到了 Kong 的问题,我创建了我的服务和路线,与 Kong 文档的 5 分钟快速入门完全相同,但我只更改了一些参数,以使用我自己在 localhost:3000 上工作的 api 设置服务。
所以这是我的设置:
这就是我为创建我的服务所做的事情。
我使用参数创建了我的服务:
{
"name": "users",
"url": "http://localhost:3000",
"host": "127.0.0.1"
}
Run Code Online (Sandbox Code Playgroud)
然后我用 body 创建了路线:
{
"hosts": [ "127.0.0.1"],
"methods": ["GET"],
"paths": ["/"],
"name": "users"
}
Run Code Online (Sandbox Code Playgroud)
然后我尝试是否一切都与http://localhost:8080/users一起使用,标题为:“Host:127.0.0.1”
我得到了回复:
502 Bad Gateway:从上游服务器收到无效响应
2019/03/04 09:28:36 [错误] 36#0: *63824 connect() 在连接到上游时失败(111:连接被拒绝),客户端:172.18.0.1,服务器:kong,请求:“GET /users HTTP/1.1”,上游:“ http://127.0.0.1:3000/users ”,主机:“127.0.0.1”
因此我们可以看到 Kong 尝试访问良好端点 '127.0.0.1:3000/' 但无法访问它。
也许 Kong 尝试访问的是自己的容器本地主机,但我不知道,而且我不知道如何修复它,也许你可以帮助我!
这是我尝试过的
docker run --rm \
> --link kong-database:kong-database \
> -e "KONG_DATABASE=postgres" \
> -e "KONG_PG_HOST=kong-database" \
> kong:latest kong migrations up
Run Code Online (Sandbox Code Playgroud)
但我有
Error: cannot run migrations: database needs bootstrapping; run 'kong migrations bootstrap'
Run Code Online (Sandbox Code Playgroud)
我不明白这实际上意味着什么。如果我尝试
docker run --rm --link kong-database:kong-database -e "KONG_DATABASE=postgres" -e "KONG_PG_HOST=kong-database" kong:latest kong migrations bootstrap
bootstrapping database...
Error: [PostgreSQL error] failed to bootstrap database: ERROR: syntax error at or near "NOT" (150)
Run Code Online (Sandbox Code Playgroud)
我检查了kong-database
{
"Id": "d94ac442da9a399c1b865de49904e01085abe1ed8f0871af5830810c4c2a78dd",
"Created": "2019-04-19T07:18:59.534751317Z",
"Path": "docker-entrypoint.sh",
"Args": [
"postgres"
],
"State": {
"Status": …Run Code Online (Sandbox Code Playgroud) kong ×10
docker ×4
postgresql ×3
api-gateway ×2
api-security ×1
cassandra ×1
centos ×1
curl ×1
lua ×1
nosql ×1
ubuntu ×1
web-services ×1