当前位置: 首页 > article >正文

apisix 本地开发环境部署

apisix 本地开发环境部署

本地开发环境部署可以采用 docker-compose 部署,配置文件如下

apisix 配置文件

apisix:
  node_listen: 9080 # APISIX 节点监听地址
  enable_ipv6: false
  http:
    port: 9080 # APISIX HTTP 端口
  #https:
  #  port: 9443 # APISIX HTTPS 端口
  #  ssl_cert: /usr/local/apisix/ssl/apisix.crt # APISIX HTTPS 证书
  #  ssl_cert_key: /usr/local/apisix/ssl/apisix.key # APISIX HTTPS 证书密钥
  log:
    level: debug # APISIX 日志级别
    ouput: ./data/apisix/logs/apisix.log # APISIX 日志输出路径

  control:
    ip: "0.0.0.0"
    port: 9092

deployment:
  type: "single" # 部署模式
  admin:
    allow_admin:
      - 0.0.0.0/0
    admin_key:
      - name: "admin" # APISIX Dashboard 管理员用户名
        key: "edd1c9f034335f136f87ad84b625c8f1" # APISIX Dashboard 管理员密码
        role: admin

  etcd:
    host:
      - "http://etcd:2379" # ETCD 集群地址
    timeout: 30 # ETCD 连接超时时间
    prefix: /apisix
    health_check_retry: 2
    tls:
      verify: false

plugins:                           # plugin list (sorted by priority)
  - request-id                     # priority: 12015
  - zipkin                         # priority: 12011
  #- skywalking                    # priority: 12010
  - opentelemetry                 # priority: 12009
  - ext-plugin-pre-req             # priority: 12000
  - fault-injection                # priority: 11000
  - mocking                        # priority: 10900
  - serverless-pre-function        # priority: 10000
  #- batch-requests                # priority: 4010
  - cors                           # priority: 4000
  - ip-restriction                 # priority: 3000
  - ua-restriction                 # priority: 2999
  - referer-restriction            # priority: 2990
  - csrf                           # priority: 2980
  - uri-blocker                    # priority: 2900
  - request-validation             # priority: 2800
  - chaitin-waf                    # priority: 2700
  - multi-auth                     # priority: 2600
  - openid-connect                 # priority: 2599
  - cas-auth                       # priority: 2597
  - authz-casbin                   # priority: 2560
  - authz-casdoor                  # priority: 2559
  - wolf-rbac                      # priority: 2555
  - ldap-auth                      # priority: 2540
  - hmac-auth                      # priority: 2530
  - basic-auth                     # priority: 2520
  - jwt-auth                       # priority: 2510
  - jwe-decrypt                    # priority: 2509
  - key-auth                       # priority: 2500
  - consumer-restriction           # priority: 2400
  - forward-auth                   # priority: 2002
  - opa                            # priority: 2001
  - authz-keycloak                 # priority: 2000
  #- error-log-logger              # priority: 1091
  - proxy-cache                    # priority: 1085
  - body-transformer               # priority: 1080
  - proxy-mirror                   # priority: 1010
  - proxy-rewrite                  # priority: 1008
  - workflow                       # priority: 1006
  - api-breaker                    # priority: 1005
  - limit-conn                     # priority: 1003
  - limit-count                    # priority: 1002
  - limit-req                      # priority: 1001
  #- node-status                   # priority: 1000
  #- brotli                        # priority: 996
  - gzip                           # priority: 995
  - server-info                    # priority: 990
  - traffic-split                  # priority: 966
  - redirect                       # priority: 900
  - response-rewrite               # priority: 899
  - degraphql                      # priority: 509
  - kafka-proxy                    # priority: 508
  #- dubbo-proxy                   # priority: 507
  - grpc-transcode                 # priority: 506
  - grpc-web                       # priority: 505
  - public-api                     # priority: 501
  - prometheus                     # priority: 500
  - datadog                        # priority: 495
  - loki-logger                    # priority: 414
  - elasticsearch-logger           # priority: 413
  - echo                           # priority: 412
  - loggly                         # priority: 411
  - http-logger                    # priority: 410
  - splunk-hec-logging             # priority: 409
  - skywalking-logger              # priority: 408
  - google-cloud-logging           # priority: 407
  - sls-logger                     # priority: 406
  - tcp-logger                     # priority: 405
  - kafka-logger                   # priority: 403
  - rocketmq-logger                # priority: 402
  - syslog                         # priority: 401
  - udp-logger                     # priority: 400
  - file-logger                    # priority: 399
  - clickhouse-logger              # priority: 398
  - tencent-cloud-cls              # priority: 397
  - inspect                        # priority: 200
  #- log-rotate                    # priority: 100
  # <- recommend to use priority (0, 100) for your custom plugins
  - example-plugin                 # priority: 0
  #- gm                            # priority: -43
  - aws-lambda                     # priority: -1899
  - azure-functions                # priority: -1900
  - openwhisk                      # priority: -1901
  - openfunction                   # priority: -1902
  - serverless-post-function       # priority: -2000
  - ext-plugin-post-req            # priority: -3000
  - ext-plugin-post-resp           # priority: -4000

stream_plugins:                    # stream plugin list (sorted by priority)
  - ip-restriction                 # priority: 3000
  - limit-conn                     # priority: 1003
  - mqtt-proxy                     # priority: 1000
  #- prometheus                    # priority: 500
  - syslog                         # priority: 401
  # <- recommend to use priority (0, 100) for your custom plugins


# wasm:
#   plugins:
#     - name: wasm_log
#       priority: 7999
#       file: t/wasm/log/main.go.wasm

# xrpc:
#   protocols:
#     - name: pingpong
plugin_attr:
  opentelemetry:
    batch_span_processor:
      batch_timeout: 2
      drop_on_queue_full: false
      inactive_timeout: 1
      max_export_batch_size: 2
      max_queue_size: 6
    collector:
      address: otel-collector:4318
      request_timeout: 3
    resource:
      service.name: APISIX
    trace_id_source: x-request-id%

apisix-dashboard 配置文件

conf:
  listen:
    host: 0.0.0.0
    port: 9000
  etcd:
    endpoints:
      - http://etcd:2379
    prefix: /apisix

authentication:
  expire_time: 3600
  users:
    - username: admin
      password: admin
    - username: user
      password: user%

dashboard-compose 配置文件

version: '3.8'

services:
  apisix:
    container_name: apisix
    platform: linux/amd64
    restart: always
    image: apache/apisix:latest
    volumes:
      - ./deploy/apisix.yml:/usr/local/apisix/conf/config.yaml:ro
      - ./data/apisix:/data
    ports:
      - 9080:9080
      - 9180:9180
      - 9091:9091
      - 9443:9443
      - 9092:9092
    networks:
      - apisix
  dashboard:
    container_name: apisix-dashboard
    platform: linux/amd64
    image: apache/apisix-dashboard:2.8
    restart: always
    volumes:
      - ./deploy/apisix-dashboard.yml:/usr/local/apisix-dashboard/conf/conf.yaml:ro
      - ./deploy/apisix-dashboard/schema.json:/usr/local/apisix-dashboard/conf/schema.json
      - ./data/dashboard:/data
    depends_on:
      - etcd
    ports:
      - "9000:9000/tcp"
    networks:
      - apisix

  etcd:
    container_name: etcd
    image: bitnami/etcd:3
    platform: linux/amd64
    volumes:
      - ./data/etcd/data:/bitnami/etcd/data
    environment:
      - ALLOW_NONE_AUTHENTICATION=yes
      - ETCD_ADVERTISE_CLIENT_URLS=http://etcd:2379
    ports:
      - 2379:2379
      - 2380:2380
    networks:
      - apisix
networks:
  apisix:
    driver: bridge
  • 其中,在 dashboard-compose 新建 deploy 文件存放 apisix-dashboard.yml 和 apisix.yml 文件,deploy/apisix-dashboard 存放 schema.json 这个schema.json 是 apisix-dashboard 的插件配置文件
  • 在 /data/etcd/data 下存放 etcd配置文件,配置文件如下
name: 'etcd'
data-dir: '/bitnami/etcd/data'
listen-client-urls: 'http://0.0.0.0:2379'
advertise-client-urls: 'http://etcd:2379'
listen-peer-urls: 'http://0.0.0.0:2380'
initial-advertise-peer-urls: 'http://etcd:2380'
initial-cluster: 'etcd=http://etcd:2380'
initial-cluster-token: 'etcd-cluster'
initial-cluster-state: 'new'

最终我们的目录结构

在这里插入图片描述

使用 docker-compose -f dashboard-compose-local.yaml up -d 将apisix 在本地部署起来


http://www.kler.cn/a/283317.html

相关文章:

  • 宗馥莉的接班挑战:内斗升级,竞品“偷家”
  • HarmonyOS的@State装饰器的底层实现
  • redis bind 127.0.0.1和bind 10.34.56.78的区别
  • 陪诊问诊APP开发实战:基于互联网医院系统源码的搭建详解
  • Qt 和 WPF(Windows Presentation Foundation)
  • 数据挖掘(九)
  • iOS/iPadOS18.1Beta3发布,新增通知摘要和AI消除功能
  • 如何在CenOS7上安装docker
  • PostgreSQL:后端开发者的瑞士军刀
  • 给自己复盘用的tjxt笔记day12第一部分
  • 【原型设计工具评测】Axure、Figma、Sketch三强争霸
  • 关于stm32的硬件CRC32与U盘分区中的CRC32计算方式不同的探索;stm32的硬件CRC32的使用细节;stm32的硬件CRC32的问题;
  • gin 通过 OpenTelemetry 实现链路追踪
  • 上新!Matlab实现基于QRGRU-Attention分位数回归门控循环单元注意力机制的时间序列区间预测模型
  • 数学基础 -- 线性代数之增广矩阵
  • Redis缓存穿透、缓存击穿与缓存雪崩的详细讲解和案例示范
  • 【WiFi协议的发展学习1】
  • SpringTask定时任务笔记
  • 仿BOSS招聘系统开发:构建高效、智能的在线招聘平台
  • Hadoop集群运维管理
  • OZON新品藏品,OZON收藏品推荐
  • LeetCode - 4 寻找两个正序数组的中位数
  • Pytorch 自动微分注意点讲解
  • 在 MySQL 中使用 `REPLACE` 函数
  • python实现蚁群算法
  • Google 插件推荐 50 个