Easy-DotNET Easy-DotNET
🏠首页
  • 知识地图
  • 源码脑图

    • 总览
    • Program
    • WebApplication
    • Host主机
    • WebHost主机
    • 依赖注入
    • Autofac
    • Middleware中间件
    • RateLimiter限制速率
    • 响应缓存、请求解压缩
  • 设计初衷
  • 克隆
  • 类型转换
  • 日期时间
  • IO流
  • 工具类
  • 语言特性
  • 集合类
  • Codec编码
  • 文本操作
  • 数学
  • 图片
  • 网络
  • Emoji表情
  • C# 12
  • C# 11
  • C# 10
  • C# 9.0
  • C# 8.0
  • C# 早期版本
  • C# 教程
  • ORM
  • 定时任务
  • 日志
  • 认证与授权
  • Swagger
  • 对象映射
  • 熔断重试限流
  • 缓存
  • 注册发现
  • 网关
  • GraphQL
  • 更多
  • Docker

    • 简介
    • Adminer
    • Apisix
    • Apollo
    • Cassandra
    • Cerebro
    • ClickHouse
    • Consul
    • EasyMock
    • Elasticsearch
    • Emqx
    • FastDFS
    • Flink
    • Gitlab
    • Jenkins
    • Jrebel
    • MariaDB
    • MySQL
    • Percona
    • Phpmyadmin
    • PostgreSQL
    • Redis
  • Linux

    • 查看Linux系统信息
    • CentOS7调整磁盘分区
    • IO压测
    • 图形化监控工具Cockpit
  • 总览
  • 列表

    • 算法数据结构
    • API
    • 应用框架
    • 应用模板
    • 操作系统
    • 工作流
    • 入门套件
    • 示例
    • 人工智能
    • 程序集
    • Assets
    • 认证授权
    • Blazor
    • 区块链
    • 书籍
    • 自动构建
    • 报表
    • 缓存
    • 日历
    • 聊天
    • CLI
    • CLR
    • CMS
    • 代码分析和指标
    • 代码片段
    • 压缩
    • 持续集成
    • 密码学
    • 数据库
    • 数据库驱动
    • 日期时间
    • 反编译
    • 部署
    • DirectX
    • 分布式计算
    • DLR
    • 文档
    • 电商支付
    • 模拟器
    • 环境管理
    • ETL
    • 事件消息
    • Exception
    • 扩展
    • 函数式编程
    • 游戏引擎
    • GIS
    • Git工具
    • 绘图
    • GraphQL
    • GUI
    • HTML-CSS
    • HTTP
    • IDE
    • 图片处理
    • 安装工具
    • 交互式编程
    • 国际化
    • 互操作性
    • IoC
    • JS引擎
    • 日志
    • 机器学习和数据科学
    • Markdown
    • 邮件
    • 数学
    • 媒体
    • 指标
    • 微型框架
    • 最小化器
    • MVVM
    • 网络
    • 对象映射
    • Office
    • OpenAI
    • ORM
    • 包管理器
    • PDF
    • 性能分析工具
    • 协议
    • 推送通知
    • SQL构建器
    • 消息队列
    • RPC
    • 响应式编程
    • 实时通信
    • 正则表达式
    • 任务调度
    • SDK和API
    • 搜索引擎
    • 序列化
    • SMS
    • 状态机
    • 静态站点生成
    • 强命名
    • 风格指南
    • 模板引擎
    • 测试
    • 工具
    • 交易
    • UI自动测试
    • Visual Studio 插件
    • Web浏览器
    • Web框架
    • WebServers
    • WebSocket
    • Windows服务
    • WPF
    • 解析器
    • 源码生成
    • 其他
    • 资源
  • AspNetCore面试题
  • Elasticsearch面试题
  • MongoDB面试题
  • MySql面试题
  • Nginx面试题
  • RabbitMQ面试题
  • Redis面试题
  • 设计模式
  • 微服务
🧑‍💻.NET Blog
GitHub (opens new window)
🏠首页
  • 知识地图
  • 源码脑图

    • 总览
    • Program
    • WebApplication
    • Host主机
    • WebHost主机
    • 依赖注入
    • Autofac
    • Middleware中间件
    • RateLimiter限制速率
    • 响应缓存、请求解压缩
  • 设计初衷
  • 克隆
  • 类型转换
  • 日期时间
  • IO流
  • 工具类
  • 语言特性
  • 集合类
  • Codec编码
  • 文本操作
  • 数学
  • 图片
  • 网络
  • Emoji表情
  • C# 12
  • C# 11
  • C# 10
  • C# 9.0
  • C# 8.0
  • C# 早期版本
  • C# 教程
  • ORM
  • 定时任务
  • 日志
  • 认证与授权
  • Swagger
  • 对象映射
  • 熔断重试限流
  • 缓存
  • 注册发现
  • 网关
  • GraphQL
  • 更多
  • Docker

    • 简介
    • Adminer
    • Apisix
    • Apollo
    • Cassandra
    • Cerebro
    • ClickHouse
    • Consul
    • EasyMock
    • Elasticsearch
    • Emqx
    • FastDFS
    • Flink
    • Gitlab
    • Jenkins
    • Jrebel
    • MariaDB
    • MySQL
    • Percona
    • Phpmyadmin
    • PostgreSQL
    • Redis
  • Linux

    • 查看Linux系统信息
    • CentOS7调整磁盘分区
    • IO压测
    • 图形化监控工具Cockpit
  • 总览
  • 列表

    • 算法数据结构
    • API
    • 应用框架
    • 应用模板
    • 操作系统
    • 工作流
    • 入门套件
    • 示例
    • 人工智能
    • 程序集
    • Assets
    • 认证授权
    • Blazor
    • 区块链
    • 书籍
    • 自动构建
    • 报表
    • 缓存
    • 日历
    • 聊天
    • CLI
    • CLR
    • CMS
    • 代码分析和指标
    • 代码片段
    • 压缩
    • 持续集成
    • 密码学
    • 数据库
    • 数据库驱动
    • 日期时间
    • 反编译
    • 部署
    • DirectX
    • 分布式计算
    • DLR
    • 文档
    • 电商支付
    • 模拟器
    • 环境管理
    • ETL
    • 事件消息
    • Exception
    • 扩展
    • 函数式编程
    • 游戏引擎
    • GIS
    • Git工具
    • 绘图
    • GraphQL
    • GUI
    • HTML-CSS
    • HTTP
    • IDE
    • 图片处理
    • 安装工具
    • 交互式编程
    • 国际化
    • 互操作性
    • IoC
    • JS引擎
    • 日志
    • 机器学习和数据科学
    • Markdown
    • 邮件
    • 数学
    • 媒体
    • 指标
    • 微型框架
    • 最小化器
    • MVVM
    • 网络
    • 对象映射
    • Office
    • OpenAI
    • ORM
    • 包管理器
    • PDF
    • 性能分析工具
    • 协议
    • 推送通知
    • SQL构建器
    • 消息队列
    • RPC
    • 响应式编程
    • 实时通信
    • 正则表达式
    • 任务调度
    • SDK和API
    • 搜索引擎
    • 序列化
    • SMS
    • 状态机
    • 静态站点生成
    • 强命名
    • 风格指南
    • 模板引擎
    • 测试
    • 工具
    • 交易
    • UI自动测试
    • Visual Studio 插件
    • Web浏览器
    • Web框架
    • WebServers
    • WebSocket
    • Windows服务
    • WPF
    • 解析器
    • 源码生成
    • 其他
    • 资源
  • AspNetCore面试题
  • Elasticsearch面试题
  • MongoDB面试题
  • MySql面试题
  • Nginx面试题
  • RabbitMQ面试题
  • Redis面试题
  • 设计模式
  • 微服务
🧑‍💻.NET Blog
GitHub (opens new window)
npm
  • Docker

    • 开源简介
    • Adminer
    • Apisix
      • Apache APISIX 云原生 API 网关
      • 简介
        • 主要特性
      • 主要概念
      • docker-compose.yml
      • apisix_conf/config.yaml
      • dashboard_conf/conf.yaml
      • deploy.sh
    • Apollo
    • Cassandra
    • Cerebro
    • ClickHouse
    • Consul
    • EasyMock
    • Elasticsearch
    • Emqx
    • FastDFS
    • Flink
    • Gitlab
    • Jenkins
    • Jrebel
    • MariaDB
    • MySQL
    • Percona
    • Phpmyadmin
    • PostgreSQL
    • Redis
  • Linux

    • 查看Linux系统信息
    • CentOS7调整磁盘分区
    • IO压测
    • Linux图形化监控工具Cockpit
    • CentOS7安装mysql5.7
目录

Apisix

# Apache APISIX 云原生 API 网关

开源网址

官网:https://apisix.apache.org/

github:https://github.com/apache/apisix

# 简介

Apache APISIX 是 Apache 软件基金会下的云原生 API 网关,它兼具动态、实时、高性能等特点,提供了负载均衡、动态上游、灰度发布(金丝雀发布)、服务熔断、身份认证、可观测性等丰富的流量管理功能。我们可以使用 Apache APISIX 来处理传统的南北向流量,也可以处理服务间的东西向流量。同时,它也支持作为 K8s Ingress Controller (opens new window) 来使用。

# 主要特性

  • 多平台支持:APISIX 提供了多平台解决方案,它不但支持裸机运行,也支持在 Kubernetes 中使用,还支持与 AWS Lambda、Azure Function、Lua 函数和 Apache OpenWhisk 等云服务集成。
  • 全动态能力:APISIX 支持热加载,这意味着你不需要重启服务就可以更新 APISIX 的配置。请访问为什么 Apache APISIX 选择 Nginx + Lua 这个技术栈? (opens new window)以了解实现原理。
  • 精细化路由:APISIX 支持使用 NGINX 内置变量 (opens new window)做为路由的匹配条件,你可以自定义匹配函数来过滤请求,匹配路由。
  • 运维友好:APISIX 支持与以下工具和平台集成:HashiCorp Vault (opens new window)、Zipkin (opens new window)、Apache SkyWalking (opens new window)、Consul (opens new window)、Nacos (opens new window)、Eureka (opens new window)。通过 APISIX Dashboard (opens new window),运维人员可以通过友好且直观的 UI 配置 APISIX。
  • 多语言插件支持:APISIX 支持多种开发语言进行插件开发,开发人员可以选择擅长语言的 SDK 开发自定义插件。

# 主要概念

下图为 Apache APISIX 的架构:

apisix

下表是本文涉及到的 APISIX 的主要概念和组件:

概念/组件 描述
Route 通过路由定义规则来匹配客户端请求,根据匹配结果加载并执行相应的插件,最后把请求转发给到指定的上游应用。
Upstream 上游的作用是按照配置规则对服务节点进行负载均衡,它的地址信息可以直接配置到路由或服务上。
Admin API 用户可以通过 Admin API 控制 APISIX 实例。

# docker-compose.yml

version: '3.7'
services: 
  apisix-dashboard:
    image: apache/apisix-dashboard:2.13-alpine
    container_name: apisix-dashboard
    restart: always
    volumes:
    - /etc/apisix/dashboard_conf/conf.yaml:/usr/local/apisix-dashboard/conf/conf.yaml
    ports:
    - "9000:9000"

  apisix:
    image: apache/apisix:2.15.0-alpine
    container_name: apisix
    restart: always
    volumes:
      - apisix_log:/usr/local/apisix/logs
      - /etc/apisix/apisix_conf/config.yaml:/usr/local/apisix/conf/config.yaml:ro
    depends_on:
      - etcd
    ##network_mode: host
    ports:
      - "9080:9080/tcp"
      - "9091:9091/tcp"
      - "9443:9443/tcp"
      - "9092:9092/tcp"

  etcd:
    image: bitnami/etcd:3.4.14
    container_name: etcd
    restart: always
    volumes:
      - etcd:/bitnami/etcd
    environment:
      ETCD_ENABLE_V2: "true"
      ALLOW_NONE_AUTHENTICATION: "yes"
      ETCD_ADVERTISE_CLIENT_URLS: "http://0.0.0.0:2379"
      ETCD_LISTEN_CLIENT_URLS: "http://0.0.0.0:2379"
    ports:
      - "2379:2379/tcp"

volumes: 
  apisix_log: 
  etcd: 

# apisix_conf/config.yaml

apisix:
  node_listen: 9080              # APISIX listening port
  enable_ipv6: false

  allow_admin:                  # http://nginx.org/en/docs/http/ngx_http_access_module.html#allow
    - 0.0.0.0/0              # We need to restrict ip access rules for security. 0.0.0.0/0 is for test.

  admin_key:
    - name: "admin"
      key: edd1c9f034335f136f87ad84b625c8f1
      role: admin                 # admin: manage all configuration data
                                  # viewer: only can view configuration data
    - name: "viewer"
      key: 4054f7cf07e344346cd3f287985e76a2
      role: viewer
  
  enable_control: true
  control:
    ip: "0.0.0.0"
    port: 9092

etcd:
  host:                           # it's possible to define multiple etcd hosts addresses of the same etcd cluster.
    - "http://etcd:2379"     # multiple etcd address
  prefix: "/apisix"               # apisix configurations prefix
  timeout: 30                     # 30 seconds

plugin_attr:
  prometheus:
    export_addr:
      ip: "0.0.0.0"
      port: 9091

# dashboard_conf/conf.yaml

conf:
  listen:
    host: 0.0.0.0     # `manager api` listening ip or host name
    port: 9000          # `manager api` listening port
  allow_list:           # If we don't set any IP list, then any IP access is allowed by default.
    - 0.0.0.0/0
  etcd:
    endpoints:          # supports defining multiple etcd host addresses for an etcd cluster
      - "http://etcd:2379"
                          # yamllint disable rule:comments-indentation
                          # etcd basic auth info
    # username: "root"    # ignore etcd username if not enable etcd auth
    # password: "123456"  # ignore etcd password if not enable etcd auth
    mtls:
      key_file: ""          # Path of your self-signed client side key
      cert_file: ""         # Path of your self-signed client side cert
      ca_file: ""           # Path of your self-signed ca cert, the CA is used to sign callers' certificates
    # prefix: /apisix     # apisix config's prefix in etcd, /apisix by default
  log:
    error_log:
      level: warn       # supports levels, lower to higher: debug, info, warn, error, panic, fatal
      file_path:
        logs/error.log  # supports relative path, absolute path, standard output
                        # such as: logs/error.log, /tmp/logs/error.log, /dev/stdout, /dev/stderr
    access_log:
      file_path:
        logs/access.log  # supports relative path, absolute path, standard output
                         # such as: logs/access.log, /tmp/logs/access.log, /dev/stdout, /dev/stderr
                         # log example: 2020-12-09T16:38:09.039+0800	INFO	filter/logging.go:46	/apisix/admin/routes/r1	{"status": 401, "host": "127.0.0.1:9000", "query": "asdfsafd=adf&a=a", "requestId": "3d50ecb8-758c-46d1-af5b-cd9d1c820156", "latency": 0, "remoteIP": "127.0.0.1", "method": "PUT", "errs": []}
authentication:
  secret:
    secret              # secret for jwt token generation.
                        # NOTE: Highly recommended to modify this value to protect `manager api`.
                        # if it's default value, when `manager api` start, it will generate a random string to replace it.
  expire_time: 3600     # jwt token expire time, in second
  users:                # yamllint enable rule:comments-indentation
    - username: admin   # username and password for login `manager api`
      password: admin
    - username: user
      password: user

plugins:                          # plugin list (sorted in alphabetical order)
  - api-breaker
  - authz-keycloak
  - basic-auth
  - batch-requests
  - consumer-restriction
  - cors
  # - dubbo-proxy
  - echo
  # - error-log-logger
  # - example-plugin
  - fault-injection
  - grpc-transcode
  - hmac-auth
  - http-logger
  - ip-restriction
  - jwt-auth
  - kafka-logger
  - key-auth
  - limit-conn
  - limit-count
  - limit-req
  # - log-rotate
  # - node-status
  - openid-connect
  - prometheus
  - proxy-cache
  - proxy-mirror
  - proxy-rewrite
  - redirect
  - referer-restriction
  - request-id
  - request-validation
  - response-rewrite
  - serverless-post-function
  - serverless-pre-function
  # - skywalking
  - sls-logger
  - syslog
  - tcp-logger
  - udp-logger
  - uri-blocker
  - wolf-rbac
  - zipkin
  - server-info
  - traffic-split

# deploy.sh

#!\bin\bash

mkdir -p /etc/apisix/dashboard_conf
mkdir -p /etc/apisix/apisix_conf
\cp ./dashboard_conf/conf.yaml /etc/apisix/dashboard_conf/conf.yaml -f
\cp ./apisix_conf/config.yaml /etc/apisix//apisix_conf/config.yaml -f
docker-compose up -d
上次更新: 2023/09/05, 21:16:45
Adminer
Apollo

← Adminer Apollo→

Theme by Vdoing | Copyright © 2019-2024 一个大西瓜 | MIT License | 苏ICP备2023013501号
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式