























官网:https://apisix.apache.org/
一. 拉取镜像
docker pull apache/apisix:latest
docker inspect apache/apisix:latest | findstr "Architecture"
docker run --rm apache/apisix:latest apisix version (查看版本,这里使用的是3.14.1)
docker pull milvusdb/etcd:3.5.25-r1
docker inspect milvusdb/etcd:3.5.25-r1 | findstr "Architecture"
二. 创建网络
docker network create apisix-net
docker network ls

三. 启动容器
1. 启动etcd
docker-compose.yml
etcd:
image: milvusdb/etcd:3.5.25-r1
container_name: etcd
restart: always
environment:
- ALLOW_NONE_AUTHENTICATION=yes
- ETCD_LISTEN_CLIENT_URLS=http://0.0.0.0:2379
- ETCD_ADVERTISE_CLIENT_URLS=http://etcd:2379
ports:
- "2379:2379"
volumes:
- D:\DockerMapping\etcd:/bitnami/etcd/data
networks:
- apisix-net
启动容器
docker-compose up -d etcd
测试:
curl http://localhost:2379/version
返回:{"etcdserver":"3.5.25","etcdcluster":"3.5.0"}
docker exec etcd etcdctl endpoint health
返回:127.0.0.1:2379 is healthy: successfully committed proposal: took = 6.166015ms
测试,写入数据
curl -L http://localhost:2379/v3/kv/put -X POST -H "Content-Type: application/json" -d "{\"key\":\"Zm9v\",\"value\":\"YmFy\"}"

2. 启动 apisix
apisix:
image: apache/apisix:latest
container_name: apisix
depends_on:
- etcd
restart: always
volumes:
- D:\DockerMapping\apisix\conf\config.yaml:/usr/local/apisix/conf/config.yaml
ports:
- "9080:9080" # 业务流量
- "127.0.0.1:9180:9180" # Admin 只本机
networks:
- apisix-net
创建 文件:D:\DockerMapping\apisix\conf\config.yaml
apisix:
node_listen: 9080
deployment:
role: traditional
role_traditional:
config_provider: etcd
etcd:
host:
- "http://etcd:2379"
admin: # 必须添加这部分
enable_admin_ui: true
allow_admin: # 允许访问admin API的IP段
- 0.0.0.0/0 # 允许所有IP(生产环境应限制)
admin_key: # 管理员密钥
- name: "admin" # 密钥名称
key: "edd1c9f034335f136f87ad84b625c8f1" # 密钥值(APISIX默认key)
role: admin # 角色
consul:
servers:
- "http://consul:8500" # 确保consul与apisix在同一网络,否则使用IP地址
启动容器
docker-compose up -d apisix
测试:
curl -i http://127.0.0.1:9180/apisix/admin/routes -H "X-API-KEY: edd1c9f034335f136f87ad84b625c8f1"

访问浏览器:

参考:https://apisix.apache.org/docs/apisix/next/dashboard/
使用:
end.
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。