apisix 配置 etcd TLS

镜像:apisix:2.9-alpine

如果使用 etcd TLS,需要自己构建 openresty。

安装软件

进入 apisix 容器里面执行

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# alpine 系统
apk add git
apk add patch
apk add perl
apk add make
apk add gcc
apk add linux-headers
apk add libc-dev
apk add pcre-dev
# apk add openssl
apk add openssl-dev
apk add zlib-dev
apk add build-base
apk add sudo

构建 openresty 脚本

进入 apisix 容器里面执行
使用脚本:https://github.com/api7/apisix-build-tools/blob/master/build-apisix-openresty.sh

使用 etcd tls

etcd tls 证书可以自己生成

docker-compose.yml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
version: "3.8"

services:
apisix:
image: apache/apisix:2.9-alpine
container_name: apisix
hostname: apisix
ports:
- "9080:9080"
- "9443:9443"
volumes:
- ./conf/config.yaml/:/usr/local/apisix/conf/config.yaml
- ./ssl:/usr/local/apisix/ssl
- ./logs:/usr/local/apisix/logs
environment:
- "TZ=Asia/Shanghai"
restart: always

config.yaml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
apisix:
id: "yl-mac"
node_listen: 9080
enable_ipv6: false

....

ssl:
ssl_trusted_certificate: /usr/local/apisix/ssl/etcd-ca.pem

etcd:
host:
- "https://192.123.2.1:2379"
- "https://192.123.2.2:2379"
- "https://192.123.2.3:2379"
prefix: "/apisix"
timeout: 30
tls:
cert: /usr/local/apisix/ssl/etcd.pem
key: /usr/local/apisix/ssl/etcd-key.pem
verify: true
  • 本文作者: forever杨
  • 本文链接: https://blog.yl-online.top/posts/5396d6c2.html
  • 版权声明: 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。如果文章内容对你有用,请记录到你的笔记中。本博客站点随时会停止服务,请不要收藏、转载!