专属域名
文档搜索
轩辕助手
Run助手
邀请有礼
返回顶部
快速返回页面顶部
收起
收起工具栏
轩辕镜像 官方专业版
轩辕镜像
专业版
轩辕镜像 官方专业版
轩辕镜像
专业版
首页个人中心搜索镜像

交易
充值流量我的订单
工具
提交工单镜像收录一键安装
Npm 源Pip 源Homebrew 源
帮助
常见问题轩辕镜像免费版
其他
关于我们网站地图
热门搜索:
apigateway

adobeapiplatform/apigateway

自动构建
adobeapiplatform

基于Openresty和NGINX的高性能API网关,生产就绪,支持服务自动发现、远程配置同步及多种API管理功能。

4 次收藏下载次数: 0状态:自动构建维护者:adobeapiplatform仓库类型:镜像最近更新:2 年前
轩辕镜像,加速的不只是镜像。点击查看
中文简介
标签下载
镜像标签列表与下载命令
轩辕镜像,加速的不只是镜像。点击查看

apigateway

基于Openresty和NGINX的高性能API网关。

目录

  • 状态
  • 快速开始
  • 内部组件
  • 性能
  • 开发者指南

状态

当前项目已达到生产就绪状态。

快速开始

独立运行

bash
$ docker run --name="apigateway" \
            -p 80:80 \
            -e "LOG_LEVEL=info" \
            adobeapiplatform/apigateway:latest

结合Apache Mesos运行

bash
$ docker run --name="apigateway" \
            -p 80:80 \
            -e "MARATHON_HOST=http://<marathon_host>:<port>" \
            -e "LOG_LEVEL=info" \
            adobeapiplatform/apigateway:latest

此命令启动的API网关会自动发现Marathon中运行的服务,并通过独立虚拟主机(VHost)暴露这些服务,具体配置可参见https://github.com/adobe-apiplatform/apigateway/blob/master/api-gateway-config/conf.d/marathon_apis.conf#L36%E3%80%82

本地访问Marathon应用

例如,若有一个名为hello-world的应用,可通过以下两种方式访问其虚拟主机:

  1. 编辑/etc/hosts,添加<docker_host_ip> hello-world.api.localhost,然后在浏览器中访问http://hello-world.api.localhost
  2. 在curl命令中指定Host头:curl -H "Host:hello-world.api.localhost" http://<docker_host_ip>

https://github.com/adobe-apiplatform/apigateway/blob/master/api-gateway-config/marathon-service-discovery.sh%E4%BB%85%E4%BD%9C%E4%B8%BA%E5%BF%AB%E9%80%9F%E5%90%AF%E5%8A%A8%E7%A4%BA%E4%BE%8B%EF%BC%8C%E5%8F%AF%E6%9B%BF%E6%8D%A2%E4%B8%BA%E5%85%B6%E4%BB%96%E6%9C%8D%E5%8A%A1%E5%8F%91%E7%8E%B0%E6%9C%BA%E5%88%B6%E3%80%82%E8%AF%A5%E8%84%9A%E6%9C%AC%E4%BC%9A%E6%9B%B4%E6%96%B0%E5%8C%85%E5%90%AB%E6%89%80%E6%9C%89NGINX%E4%B8%8A%E6%B8%B8%E6%9C%8D%E5%8A%A1%E5%99%A8%E7%9A%84https://github.com/adobe-apiplatform/apigateway/blob/master/api-gateway-config/environment.conf.d/api-gateway-upstreams.http.conf%EF%BC%8C%E4%BE%9Bhttps://github.com/adobe-apiplatform/apigateway/blob/master/api-gateway-config/conf.d/marathon_apis.conf#L36%E4%BD%BF%E7%94%A8%E3%80%82

远程访问Marathon应用

只需创建类似*.api.example.com或*.gw.example.com的DNS记录,使其解析到运行网关的节点即可。

假设Marathon中部署了名为hello-world的应用,可通过URL http://hello-world.api.example.com访问,网关会自动将请求代理到Marathon中的hello-world应用。

若访问http://my-custom-app.api.example.com,网关会代理到名为my-custom-app的Marathon应用。若该应用未部署,将返回5xx错误(此行为可配置)。

使用不同的配置文件夹

简化网关配置的一种方式是将api-gateway-config文件夹复制到S3,让所有节点从该位置同步配置。目前仅支持AWS S3,计划添加对其他云平台的支持。

要使用S3,需通过环境变量REMOTE_CONFIG指定存储桶:

bash
docker run --name="apigateway" \
            -p 80:80 \
            -e "MARATHON_HOST=http://<marathon_host>:<port>" \
            -e "REMOTE_CONFIG=s3://api-gateway-config-bucket" \
            -e "LOG_LEVEL=info" \
            adobeapiplatform/apigateway:latest

s3://api-gateway-config-bucket应包含与https://github.com/adobe-apiplatform/apigateway/blob/master/api-gateway-config/%E6%96%87%E4%BB%B6%E5%A4%B9%E7%B1%BB%E4%BC%BC%E7%9A%84%E5%86%85%E5%AE%B9%EF%BC%8C%E5%BB%BA%E8%AE%AE%E5%9F%BA%E4%BA%8E%E8%AF%A5%E6%96%87%E4%BB%B6%E5%A4%B9%E8%BF%9B%E8%A1%8C%E8%87%AA%E5%AE%9A%E4%B9%89%E3%80%82%E4%BB%A5%E4%B8%8B%E4%B8%A4%E4%B8%AA%E6%96%87%E4%BB%B6%E4%B8%8D%E4%BC%9A%E8%A2%AB%E5%90%8C%E6%AD%A5%EF%BC%9A

  • /etc/api-gateway/conf.d/includes/resolvers.conf(详见下文说明)
  • https://github.com/adobe-apiplatform/apigateway/blob/master/api-gateway-config/environment.conf.d/api-gateway-upstreams.http.conf%EF%BC%88%E7%94%B1Marathon%E5%8F%91%E7%8E%B0%E8%84%9A%E6%9C%AC%E8%87%AA%E5%8A%A8%E7%94%9F%E6%88%90%EF%BC%89

默认通过IAM角色访问S3存储桶,也可通过环境变量指定AWS凭证:

bash
docker run --name="apigateway" \
            -p 80:80 \
            -e "MARATHON_HOST=http://<marathon_host>:<port>" \
            -e "REMOTE_CONFIG=s3://api-gateway-config-bucket" \
            -e "AWS_ACCESS_KEY_ID=--change-me--" \
            -e "AWS_SECRET_ACCESS_KEY=--change-me--" \
            -e "LOG_LEVEL=info" \
            adobeapiplatform/apigateway:latest

默认每10s检查一次远程配置变更,可通过REMOTE_CONFIG_SYNC_INTERVAL环境变量调整间隔。修改时需考虑:

  • 配置实际变更频率
  • 成本(如S3中72个文件每10s检查一次成本约为$7.46,每30s检查约为$2.4,需乘以网关节点数)
  • API请求平均时间(重载网关时,处理活动连接的现有NGINX进程会在后台保留直至请求完成,过于频繁的重载可能导致同时运行的进程过多)

自定义同步命令

可通过REMOTE_CONFIG_SYNC_CMD环境变量控制用于下载配置文件的同步命令,此变量会覆盖REMOTE_CONFIG。

解析器

容器启动时会自动根据/etc/resolv.conf创建/etc/api-gateway/conf.d/includes/resolvers.conf配置文件。关于NGINX的resolver指令,详见文档。

在Marathon和Mesos之外运行API网关

除依赖Marathon的服务发现部分外,API网关也可独立运行。Marathon服务发现通过-e "MARATHON_HOST=http://<marathon_host>:<port>/"启用。

内部组件

核心组件

模块版本详情
https://github.com/openresty/1.13.6.1安装路径:/usr/local/sbin/api-gateway
带--with-debug编译的https://github.com/openresty/1.13.6.1安装路径:/usr/local/sbin/api-gateway-debug,支持调试日志
https://github.com/openresty/test-nginxhttps://github.com/openresty/test-nginx/releases/tag/v0.24用于在容器内执行集成测试,安装路径:/usr/local/test-nginx-0.24/,Docker构建时用于对Lua模块执行make test
PCRE8.37支持PCRE JIT
ZeroMQ4.0.5ZeroMQ
CZMQ2.2.0ZeroMQ的高级C绑定

API管理和日志模块

模块版本描述
https://github.com/adobe-apiplatform/api-gateway-config-supervisorhttps://github.com/adobe-apiplatform/api-gateway-config-supervisor/releases/tag/1.0.3从Amazon S3同步配置文件并重载网关
https://github.com/adobe-apiplatform/api-gateway-cachemanagerhttps://github.com/adobe-apiplatform/api-gateway-cachemanager/releases/tag/1.0.1用于管理多个缓存存储的Lua库
https://github.com/adobe-apiplatform/api-gateway-hmachttps://github.com/adobe-apiplatform/api-gateway-hmac/releases/tag/1.0.0通过OpenSSL和FFI支持多种算法的Lua HMAC实现
https://github.com/adobe-apiplatform/api-gateway-awshttps://github.com/adobe-apiplatform/api-gateway-aws/releases/tag/1.7.1Nginx的Lua AWS SDK
https://github.com/adobe-apiplatform/api-gateway-request-validationhttps://github.com/adobe-apiplatform/api-gateway-request-validation/releases/tag/1.2.4API请求验证框架
https://github.com/adobe-apiplatform/api-gateway-async-loggerhttps://github.com/adobe-apiplatform/api-gateway-async-logger/releases/tag/1.0.1高性能异步日志器
https://github.com/adobe-apiplatform/api-gateway-zmq-loggerhttps://github.com/adobe-apiplatform/api-gateway-zmq-logger/releases/tag/1.0.0基于FFI和CZMQ的Lua ZMQ日志器
https://github.com/adobe-apiplatform/api-gateway-request-trackinghttps://github.com/adobe-apiplatform/api-gateway-request-tracking/releases/tag/1.0.1API网关的使用和跟踪处理器

其他Lua模块

模块版本描述
https://github.com/pintsized/lua-resty-httphttps://github.com/pintsized/lua-resty-http/releases/tag/v0.07OpenResty/ngx_lua的Lua HTTP客户端cosocket驱动
https://github.com/hamishforbes/lua-resty-iputilshttps://github.com/hamishforbes/lua-resty-iputils/releases/tag/v0.2.0Openresty中处理IP地址的工具函数

性能

以下性能测试结果在8核CPU、4GB内存的虚拟机上获得。

API网关容器使用4核CPU和net=host模式启动:

bash
docker run --cpuset-cpus=0-3 --net=host --name="apigateway" -e "LOG_LEVEL=notice" adobeapiplatform/apigateway:latest

WRK测试使用4核CPU和net=host模式:

bash
docker run --cpuset-cpus=4-7 --net=host williamyeh/wrk:4.0.1 -t4 -c1000 -d30s http://<docker_host_ip>/health-check
Running 30s test @ http://192.168.75.158/health-check
  4 threads and 1000 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    30.38ms   73.80ms   1.16s    90.90%
    Req/Sec    35.26k    11.98k   83.70k    68.72%
  4214013 requests in 30.06s, 1.28GB read

Requests/sec: 140165.09

Transfer/sec:     43.57MB

开发者指南

本地构建Docker镜像

bash
make docker

SSH进入新构建的镜像(非运行中镜像)

bash
make docker-ssh

运行和停止Docker镜像

bash
make docker-run

API网关主进程暴露在80端口。可通过health-check测试网关是否正常工作:

bash
$ curl http://<docker_host_ip>/health-check
  API-Platform is running!

如需快速性能测试,可使用Docker版Apache Benchmark:

bash
docker run jordi/ab ab -k -n 200000 -c 500 http://<docker_host_ip>/health-check

要将本地api-gateway-config目录挂载到容器的/etc/api-gateway/:

bash
$ make docker-debug

调试模式下,容器启动带--with-debug编译的api-gateway,提供详细调试信息。使用-e "LOG_LEVEL=info"时输出会很详细,更多信息参见NGINX文档。

停止镜像:

bash
make docker-stop

通过Redis启用API KEY管理

此命令启动两个Docker容器:redis和gateway

bash
make docker-compose

SSH进入运行中的镜像

bash
make docker-attach

在Mesos中通过Marathon运行容器

向http://<marathon-host>/v2/apps发送HTTP POST请求, payload如下。为获得最佳性能,建议将network设为HOST模式,详见Docker 文档。

javascript
{
  "id": "api-gateway",
  "container": {
    "type": "DOCKER",
    "docker": {
      "image": "adobeapiplatform/apigateway:latest",
      "forcePullImage": true,
      "network": "HOST"
    }
  },
  "cpus": 4,
  "mem": 4096.0,
  "env": {
    "MARATHON_HOST": "http://<marathon_host>:<marathon_port>"
  },
  "constraints": [  [ "hostname","UNIQUE" ]  ],
  "ports": [ 80 ],
  "healthChecks": [
    {
      "protocol": "HTTP",
      "portIndex": 0,
      "path": "/health-check",
      "gracePeriodSeconds": 3,
      "intervalSeconds": 10,
      "timeoutSeconds": 10
    }
  ],
  "instances": 1
}

如需仅在标记为slave_public的节点上运行网关,可在主JSON对象中添加:

json
"acceptedResourceRoles": [ "slave_public" ]

在网关中自动发现和注册Marathon任务

要在Mesos+Marathon框架中启用自动发现,需定义以下环境变量:

MARATHON_URL=http://<marathon-url-1>
MARATHON_TASKS=ws-.* (当前未使用,如需过滤任务可后续扩展)

对应的Docker命令:

bash
docker run --name="apigateway" \
            -p 8080:80 \
            -e "MARATHON_HOST=http://<marathon_host>:<port>/" \
            -e "LOG_LEVEL=info" \
            adobeapiplatform/apigateway:latest

镜像拉取方式

您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。

轩辕镜像加速拉取命令点我查看更多 apigateway 镜像标签

docker pull docker.xuanyuan.run/adobeapiplatform/apigateway:<标签>

使用方法:

  • 登录认证方式
  • 免认证方式

DockerHub 原生拉取命令

docker pull adobeapiplatform/apigateway:<标签>

更多 apigateway 镜像推荐

openwhisk/apigateway logo

openwhisk/apigateway

openwhisk
Apache OpenWhisk基于Openresty和NGINX的高性能API网关。
5 次收藏50万+ 次下载
4 年前更新
s3software/apigateway logo

s3software/apigateway

s3software
暂无描述
50万+ 次下载
4 年前更新
blueh10/apigateway logo

blueh10/apigateway

blueh10
暂无描述
10万+ 次下载
4 年前更新
clickerp/apigateway logo

clickerp/apigateway

clickerp
暂无描述
1万+ 次下载
5 天前更新
sebasarangom/apigateway logo

sebasarangom/apigateway

sebasarangom
Repositorio para el API Gateway.
1万+ 次下载
2 年前更新
docadercogz01/apigateway logo

docadercogz01/apigateway

docadercogz01
暂无描述
1万+ 次下载
4 年前更新

查看更多 apigateway 相关镜像

轩辕镜像配置手册

探索更多轩辕镜像的使用方法,找到最适合您系统的配置方式

Docker 配置

登录仓库拉取

通过 Docker 登录认证访问私有仓库

专属域名拉取

无需登录使用专属域名

K8s Containerd

Kubernetes 集群配置 Containerd

K3s

K3s 轻量级 Kubernetes 镜像加速

Dev Containers

VS Code Dev Containers 配置

Podman

Podman 容器引擎配置

Singularity/Apptainer

HPC 科学计算容器配置

其他仓库配置

ghcr、Quay、nvcr 等镜像仓库

Harbor 镜像源配置

Harbor Proxy Repository 对接专属域名

Portainer 镜像源配置

Portainer Registries 加速拉取

Nexus 镜像源配置

Nexus3 Docker Proxy 内网缓存

系统配置

Linux

在 Linux 系统配置镜像服务

Windows/Mac

在 Docker Desktop 配置镜像

MacOS OrbStack

MacOS OrbStack 容器配置

Docker Compose

Docker Compose 项目配置

NAS 设备

群晖

Synology 群晖 NAS 配置

飞牛

飞牛 fnOS 系统配置镜像

绿联

绿联 NAS 系统配置镜像

威联通

QNAP 威联通 NAS 配置

极空间

极空间 NAS 系统配置服务

网络设备

爱快路由

爱快 iKuai 路由系统配置

宝塔面板

在宝塔面板一键配置镜像

需要其他帮助?请查看我们的 常见问题Docker 镜像访问常见问题解答 或 提交工单

镜像拉取常见问题

使用与功能问题

配置了专属域名后,docker search 为什么会报错?

docker search 限制

Docker Hub 上有的镜像,为什么在轩辕镜像网站搜不到?

站内搜不到镜像

机器不能直连外网时,怎么用 docker save / load 迁镜像?

离线 save/load

docker pull 拉插件报错(plugin v1+json)怎么办?

插件要用 plugin install

WSL 里 Docker 拉镜像特别慢,怎么排查和优化?

WSL 拉取慢

轩辕镜像安全吗?如何用 digest 校验镜像没被篡改?

安全与 digest

第一次用轩辕镜像拉 Docker 镜像,要怎么登录和配置?

新手拉取配置

轩辕镜像合规吗?轩辕镜像的合规是怎么做的?

镜像合规机制

轩辕镜像支持 docker push 上传本地镜像吗?

不支持 push

错误码与失败问题

docker pull 提示 manifest unknown 怎么办?

manifest unknown

docker pull 提示 no matching manifest 怎么办?

no matching manifest(架构)

镜像已拉取完成,却提示 invalid tar header 或 failed to register layer 怎么办?

invalid tar header(解压)

Docker pull 时 HTTPS / TLS 证书验证失败怎么办?

TLS 证书失败

Docker pull 时 DNS 解析超时或连不上仓库怎么办?

DNS 超时

docker 无法连接轩辕镜像域名怎么办?

域名连通性排查

Docker 拉取出现 410 Gone 怎么办?

410 Gone 排查

出现 402 或「流量用尽」提示怎么办?

402 与流量用尽

Docker 拉取提示 UNAUTHORIZED(401)怎么办?

401 认证失败

遇到 429 Too Many Requests(请求太频繁)怎么办?

429 限流

docker login 提示 Cannot autolaunch D-Bus,还算登录成功吗?

D-Bus 凭证提示

为什么会出现「单层超过 20GB」或 413,无法加速拉取?

413 与超大单层

账号 / 计费 / 权限

轩辕镜像免费版和专业版有什么区别?

免费版与专业版区别

轩辕镜像支持哪些 Docker 镜像仓库?

支持的镜像仓库

镜像拉取失败还会不会扣流量?

失败是否计费

麒麟 V10 / 统信 UOS 提示 KYSEC 权限不够怎么办?

KYSEC 拦截脚本

如何在轩辕镜像申请开具发票?

申请开票

怎么修改轩辕镜像的网站登录和仓库登录密码?

修改登录密码

如何注销轩辕镜像账户?要注意什么?

注销账户

配置与原理类

写了 registry-mirrors,为什么还是走官方或仍然报错?

mirrors 不生效

怎么用 docker tag 去掉镜像名里的轩辕域名前缀?

去掉域名前缀

如何拉取指定 CPU 架构的镜像(如 ARM64、AMD64)?

指定架构拉取

用轩辕镜像拉镜像时快时慢,常见原因有哪些?

拉取速度原因

为什么拉取镜像的 :latest 标签,拿到的往往不是「最新」镜像?

latest 与「最新」

查看全部问题→

用户好评

来自真实用户的反馈,见证轩辕镜像的优质服务

用户头像

oldzhang

运维工程师

Linux服务器

5

"Docker访问体验非常流畅,大镜像也能快速完成下载。"

轩辕镜像
镜像详情
...
adobeapiplatform/apigateway
博客Docker 镜像公告与技术博客
热门查看热门 Docker 镜像推荐
安装一键安装 Docker 并配置镜像源
镜像拉取问题咨询请 提交工单。官方公众号:源码跳动。官方技术交流群:51517718。轩辕镜像所有镜像均来源于原始仓库,本站不存储、不修改、不传播任何镜像内容。
镜像拉取问题咨询请提交工单。官方公众号:源码跳动。官方技术交流群:。轩辕镜像所有镜像均来源于原始仓库,本站不存储、不修改、不传播任何镜像内容。
商务合作:点击复制邮箱
©2024-2026 源码跳动
商务合作:点击复制邮箱Copyright © 2024-2026 杭州源码跳动科技有限公司. All rights reserved.