ApiSix配置详解

  • 背景介绍
  • 配置详情

背景介绍

ApiSix官方介绍
ApiSix安装

配置详情

在centos上使用yum命令安装apisix之后, /usr/local 下会出现apisix的文件夹
apisix使用Nginx反向代理, 因而apisix配置导向nginx配置
apisix的配置文件在/usr/local/apisix/conf/config.yaml

以下是一个标准的apisix yaml配置, 笔者将相关配置详解写在注释后

apisix:node_listen: 9080              # APISIX的启动端口enable_admin: true             # 是否启用adminenable_admin_cors: true         # 允许CORS访问enable_debug: false             # debug模式enable_dev_mode: false          # True的时候nginx只会启动一个worker进程enable_reuseport: true          # True的时候nginx配置启动SO_REUSEPORT.enable_ipv6: true               # ipv6config_center: etcd             # etcd: 使用etcd做配置同步# yaml: 获取 `/usr/local/apisix/conf/apisix.yaml` 以同步配置#proxy_protocol:                 # 代理协议配置, 以下不做详解#  listen_http_port: 9181        # The port with proxy protocol for http, it differs from node_listen and port_admin.# This port can only receive http request with proxy protocol, but node_listen & port_admin# can only receive http request. If you enable proxy protocol, you must use this port to# receive http request with proxy protocol#  listen_https_port: 9182       # The port with proxy protocol for https#  enable_tcp_pp: true           # Enable the proxy protocol for tcp proxy, it works for stream_proxy.tcp option#  enable_tcp_pp_to_upstream: true # Enables the proxy protocol to the upstream serverproxy_cache:                     # Proxy Caching configurationcache_ttl: 10s                 # The default caching time if the upstream does not specify the cache timezones:                         # The parameters of a cache- name: disk_cache_one         # The name of the cache, administrator can be specify# which cache to use by name in the admin apimemory_size: 50m             # The size of shared memory, it's used to store the cache indexdisk_size: 1G                # The size of disk, it's used to store the cache datadisk_path: "/tmp/disk_cache_one" # The path to store the cache datacache_levels: "1:2"           # The hierarchy levels of a cache#  - name: disk_cache_two#    memory_size: 50m#    disk_size: 1G#    disk_path: "/tmp/disk_cache_two"#    cache_levels: "1:2"allow_admin:                  # 参考http://nginx.org/en/docs/http/ngx_http_access_module.html#allow- 192.168.0.0/16              # 如果列表为空, 所有ip都能接受(笔者测试失败)- 127.0.0.0/16#   - "::/64"                  # ipv6配置# port_admin: 9180              # use a separate port# https_admin: true             # 使用https协议访问admin, apisix默认会读取conf/apisix_admin_api.crt和conf/apisix_admin_api.key作为证书.admin_api_mtls:               # 以下配置与port_admin和https_admin相关admin_ssl_cert: ""             # 自签名服务器端证书路径admin_ssl_cert_key: ""         # 自签名服务器端密钥路径admin_ssl_ca_cert: ""          # 自签名CA证书路径.CA用来签名所有admin api调用者的证书# 使用admin api所用的默认token# 注意: 为了保护admin API, 强烈建议更改这个值# 关闭这个配置意味着admin api不需要任何认证admin_key:-name: "admin"key: edd1c9f034335f136f87ad84b625c8f1role: admin                 # admin: 管理所有的配置数据# viewer: 只能查看所有的配置数据-name: "viewer"key: 4054f7cf07e344346cd3f287985e76a2role: viewerdelete_uri_tail_slash: false    # delete the '/' at the end of the URIrouter:http: 'radixtree_uri'         # radixtree_uri: 基于基数树的uri匹配# radixtree_host_uri: 基于基数树的uri+host匹配ssl: 'radixtree_sni'          # radixtree_sni: 基于基数树的sni匹配# stream_proxy:                 # TCP/UDP proxy TCP/UDP代理, 下不详述#   tcp:                        # TCP proxy port list#     - 9100#     - 9101#   udp:                        # UDP proxy port list#     - 9200#     - 9211# dns_resolver:                   # If not set, read from `/etc/resolv.conf`#  - 1.1.1.1#  - 8.8.8.8dns_resolver_valid: 30          # dns结果有效时间30sresolver_timeout: 5             # 解析超时时间ssl:enable: trueenable_http2: truelisten_port: 9443ssl_protocols: "TLSv1.2 TLSv1.3"ssl_ciphers: "ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384"key_encrypt_salt: "edd1c9f0985e76a2"    #  如果不设置, 会保留原始的ssl key到etcd#  如果设置了, 必须是长度为16的字符串, 并且该字符串会对ssl key 以AES-128-CBC算法加密#  !!! 千万不要在保存ssl之后更改, 否则将不能解密保存的ssl keys !!
#  discovery: eureka               # 服务发现中心
nginx_config:                     # 用以渲染生成nginx_config.conf模板的配置error_log: "logs/error.log"error_log_level: "warn"         # warn,error可选值worker_rlimit_nofile: 20480     # 每个worker process可以打开的文件数量, 应当大于worker_connectionsworker_shutdown_timeout: 240s     # 正常关闭worker进程的超时时间event:worker_connections: 10620http:access_log: "logs/access.log"keepalive_timeout: 60s         # keep-alive 客户端连接在服务端的超时时间client_header_timeout: 60s     # 读取客户端请求头的超时事件, 一旦超时, 返回408给客户端client_body_timeout: 60s       # 读取客户端请求体的超时事件, 一旦超时, 返回408给客户端send_timeout: 10s              # 发送响应给客户端的超时时间, 超时之后, 连接会被关闭underscores_in_headers: "on"   # 默认允许在请求头中使用下划线real_ip_header: "X-Real-IP"    # 参考http://nginx.org/en/docs/http/ngx_http_realip_module.html#real_ip_headerreal_ip_from:                  # 参考http://nginx.org/en/docs/http/ngx_http_realip_module.html#set_real_ip_from- 127.0.0.1- 'unix:'#lua_shared_dicts:              # 在nginx.conf中添加定制的共享缓存, 定制共享缓存的格式是:`cache-key: cache-size`#  ipc_shared_dict: 100m        etcd:host:                           # it's possible to define multiple etcd hosts addresses of the same etcd cluster.- "http://127.0.0.1:2379"     # multiple etcd addressprefix: "/apisix"               # apisix configurations prefixtimeout: 30                     # 30 seconds# user: root                     # root username for etcd# password: 5tHkHhYkjr6cQY        # root password for etcd
#eureka:
#  host:                           # 可以在同一个erueka集群中定义多个eureka地址
#    - "http://127.0.0.1:8761"
#  prefix: "/eureka/"
#  fetch_interval: 30              # 默认获取间隔30秒
#  weight: 100                     # 默认weight 100
#  timeout:
#    connect: 2000                 # 默认 2000ms
#    send: 2000                    # 默认 2000ms
#    read: 5000                    # 默认 5000msplugins:                          # apisix可使用的插件列表- example-plugin- limit-req- limit-count- limit-conn- key-auth- basic-auth- prometheus- node-status- jwt-auth- zipkin- ip-restriction- grpc-transcode- serverless-pre-function- serverless-post-function- openid-connect- proxy-rewrite- redirect- response-rewrite- fault-injection- udp-logger- wolf-rbac- proxy-cache- tcp-logger- proxy-mirror- kafka-logger- cors- consumer-restriction- syslog- batch-requests- http-logger- skywalking- echo- authz-keycloak- uri-blocker- request-validationstream_plugins:                         # apisix可使用的流插件- mqtt-proxy

更改配置完成之后使用命令 apisix reload 使配置生效, 或者apisix stop; apisix start 重新启动apisix

ApiSix配置详解相关推荐

  1. elasticsearch-.yml(中文配置详解)

    此elasticsearch-.yml配置文件,是在$ES_HOME/config/下 elasticsearch-.yml(中文配置详解) # ======================== El ...

  2. (ASA) Cisco Web ××× 配置详解 [三部曲之一]

    (ASA) Cisco Web ××× 配置详解 [三部曲之一] 注意:本文仅对Web×××特性和配置作介绍,不包含SSL ×××配置,SSL ×××配置将在本版的后续文章中进行介绍.   首先,先来 ...

  3. mybatis 同名方法_MyBatis(四):xml配置详解

    目录 1.我们将 数据库的配置语句写在 db.properties 文件中 2.在 mybatis-configuration.xml 中加载db.properties文件并读取 通过源码我们可以分析 ...

  4. logback节点配置详解

    logback节点配置详解 一:根节点 <configuration></configuration> 属性 : debug : 默认为false ,设置为true时,将打印出 ...

  5. PM配置详解之一:企业结构

    1.维护计划工厂 功能说明 在公司结构中定义维护工厂(通常已经作为后勤工厂存在)和维护计划工厂(简称计划工厂). 维护工厂:设备所安装的位置,如某机组安装在合营公司,那么合营公司就是此机组的维护工厂, ...

  6. 转 Log4j.properties配置详解

    一.Log4j简介 Log4j有三个主要的组件:Loggers(记录器),Appenders (输出源)和Layouts(布局).这里可简单理解为日志类别,日志要输出的地方和日志以何种形式输出.综合使 ...

  7. Iptables防火墙配置详解

    iptables防火墙配置详解 iptables简介 iptables是基于内核的防火墙,功能非常强大,iptables内置了filter,nat和mangle三张表. (1)filter表负责过滤数 ...

  8. spring之旅第四篇-注解配置详解

    spring之旅第四篇-注解配置详解 一.引言 最近因为找工作,导致很长时间没有更新,找工作的时候你会明白浪费的时间后面都是要还的,现在的每一点努力,将来也会给你回报的,但行好事,莫问前程!努力总不会 ...

  9. php-fpm 启动参数及重要配置详解

    2019独角兽企业重金招聘Python工程师标准>>> php-fpm 启动参数及重要配置详解 约定几个目录 /usr/local/php/sbin/php-fpm /usr/loc ...

最新文章

  1. SylixOS内核打印调试方法
  2. Ubuntu 12.04安装NFS server
  3. paho mqtt client调试记录
  4. 【REST】REST是什么
  5. 一名IT经理是如何把项目带崩的。。。
  6. 写一函数,输入一个四位数字,要求输出这四个数字字符,但每两个数字间空格。如输入1990,应输出1 9 9 0。
  7. QT5开发及实例学习之九基本对话框(二)
  8. c语言程序设计笔记手写图片,C语言程序设计笔记.pdf
  9. 如何让Windows 只显示某些文件扩展名
  10. zend studio 导入已有项目
  11. 杨辉三角的几种 Python 实现方法
  12. oracle错误代码03113,Oracle ora-03113错误的处理
  13. [原创] 适合新手的转手绘教程[ JJ ]
  14. PHP正则淘口令,Flutter代码锦囊---淘口令复制弹窗
  15. java发布帖子_第一篇发在javaeye的帖子
  16. axios请求文件流下载文件
  17. Excel 多个条件同时重复时,自动标红
  18. Flask Jinja2模板引擎,headfirstjavapdf百度云
  19. python替换excel指定内容_Python脚本操作Excel实现批量替换功能
  20. 此生,依旧是我未看破红尘。

热门文章

  1. 先验概率、后验概率和似然概率
  2. 喝汽水问题(使用c语言解决)
  3. 【机器学习】saturate的解释
  4. java splash screen_Java splash screen
  5. 基础篇(6) splash应用
  6. List Dork Google
  7. 吴裕雄--天生自然 物理学习与探索笔记:冲量与动量及动量定理和波
  8. centos查看IP地址及网关
  9. 全方位解析谷歌云的基础架构在游戏场景中的独特优势
  10. 释放 ChatGPT 的潜力:人工智能的未来