跳到主要内容
版本:3.10.x

配置文件

API7 网关在 /conf 目录中提供以下配置文件:

  • config-default.yaml:包含默认配置值和供参考的内联注释。
  • config.yaml:用于用户定义的自定义配置。

默认情况下,API7 网关从 config-default.yaml 加载设置,不应修改该文件。此文件用作参考,并定义了系统的默认行为。

要自定义配置,请在 config.yaml 中添加或覆盖设置。config.yaml 中定义的任何配置均优先于 config-default.yaml 中的相应值。

自定义配置

API7 网关仅在启动时加载配置文件。要应用配置更改,请修改 config.yaml(覆盖 config-default.yaml 中的默认设置)并重新加载网关。

如果在 Docker 中运行网关,配置文件位于 /usr/local/apisix/conf/config.yaml

修改配置后,重新加载网关容器以使更改生效:

docker exec {gateway_container_name} apisix reload

默认配置

以下是 config-default.yaml 文件的内容。

config-default.yaml
apisix:
# node_listen: 9080 # APISIX 监听端口
node_listen: # 这种写法支持配置多个端口
- 9080
# - port: 9081
# enable_http2: true # 如果未设置,默认值为 `false`。
# - ip: 127.0.0.2 # 指定 IP。如果未设置,默认值为 `0.0.0.0`。
# port: 9082
# enable_http2: true
# - port: 9082
# backlog: 1024 # 设置 listen() 调用中的 backlog 参数,用于限制
# 待处理连接队列的最大长度。
# 默认情况下,FreeBSD、DragonFly BSD 和 macOS 上的 backlog 为 -1,
# 其他平台上为 511。
enable_admin: true
enable_dev_mode: false # 如果设置为 true,则将 nginx worker_processes 设置为 1
enable_reuseport: true # 如果设置为 true,则启用 nginx SO_REUSEPORT 开关。
show_upstream_status_in_response_header: false # 为 true 时将所有上游状态写入 `X-APISIX-Upstream-Status`,否则只写入 5xx 状态码
enable_ipv6: true

#proxy_protocol: # Proxy Protocol 配置
# listen_http_port: 9181 # HTTP 的 Proxy Protocol 端口,与 node_listen 和 admin_listen 不同。
# 该端口只能接收带 Proxy Protocol 的 HTTP 请求,而 node_listen 与 admin_listen
# 只能接收普通 HTTP 请求。如果启用 Proxy Protocol,必须使用该端口
# 接收带 Proxy Protocol 的 HTTP 请求
# listen_https_port: 9182 # HTTPS 的 Proxy Protocol 端口
# enable_tcp_pp: true # 为 TCP 代理启用 Proxy Protocol,适用于 stream_proxy.tcp 选项
# enable_tcp_pp_to_upstream: true # 向上游服务器启用 Proxy Protocol
enable_server_tokens: true # 是否在 Server 响应头中显示 APISIX 版本号。
# 默认启用。

# 用于加载第三方代码和/或覆盖内置代码的配置。
extra_lua_path: "" # 扩展 lua_package_path 以加载第三方代码
extra_lua_cpath: "" # 扩展 lua_package_cpath 以加载第三方代码
lua_module_hook: "agent.hook" # 用于向 APISIX 注入第三方代码的 hook 模块

proxy_cache: # 代理缓存配置
cache_ttl: 10s # 如果上游未指定缓存时间,则使用该磁盘默认缓存时间
zones: # 缓存参数
- name: disk_cache_one # 缓存名称,管理员可在 Admin API 中
# 通过名称指定使用哪个缓存(disk|memory)
memory_size: 50m # 共享内存大小。disk 策略用于存储缓存索引,
# memory 策略用于存储缓存内容(disk|memory)
disk_size: 1G # 磁盘大小,用于存储缓存数据(disk)
disk_path: /tmp/disk_cache_one # 缓存数据存储路径(disk)
cache_levels: "1:2" # 缓存层级(disk)
#- name: disk_cache_two
# memory_size: 50m
# disk_size: 1G
# disk_path: "/tmp/disk_cache_two"
# cache_levels: "1:2"
- name: memory_cache
memory_size: 50m

delete_uri_tail_slash: false # 删除 URI 末尾的 '/'
# servlet 中的 URI 规范化与 RFC 略有不同。
# 参见 https://github.com/jakartaee/servlet/blob/master/spec/src/main/asciidoc/servlet-spec-body.adoc#352-uri-path-canonicalization,
# Tomcat 会使用该规范化方式。
# 如果在匹配 URI 路径时需要兼容 servlet,请启用该选项。
normalize_uri_like_servlet: false
router:
http: radixtree_uri # radixtree_uri:按 URI 匹配路由(基于 radixtree)
# radixtree_host_uri:按 host + URI 匹配路由(基于 radixtree)
# radixtree_uri_with_parameter:类似 radixtree_uri,但会匹配带参数的 URI。
# 更多详情请参见 https://github.com/api7/lua-resty-radixtree/#parameters-in-path。
ssl: radixtree_sni # radixtree_sni:按 SNI 匹配路由(基于 radixtree)
#stream_proxy: # TCP/UDP 代理
# only: true # 仅使用 stream 代理,不启用 HTTP 相关功能
# tcp: # TCP 代理端口列表
# - addr: 9100
# tls: true
# - addr: "127.0.0.1:9101"
# udp: # UDP 代理端口列表
# - 9200
# - "127.0.0.1:9201"
#dns_resolver: # 如果未设置,则从 `/etc/resolv.conf` 读取
# - 1.1.1.1
# - 8.8.8.8
#dns_resolver_valid: 30 # 如果提供,则覆盖有效记录的 TTL。单位为秒。
resolver_timeout: 5 # 解析器超时时间
enable_resolv_search_opt: true # 启用 resolv.conf 中的 search 选项
ssl:
enable: true
listen: # APISIX HTTPS 监听端口。
- port: 9443
enable_http2: true
# - ip: 127.0.0.3 # 指定 IP。如果未设置,默认值为 `0.0.0.0`。
# port: 9445
# enable_http2: true
# - port: 9446
# backlog: 1024 # 设置 listen() 调用中的 backlog 参数,用于限制
# 待处理连接队列的最大长度。
# 默认情况下,FreeBSD、DragonFly BSD 和 macOS 上的 backlog 为 -1,
# 其他平台上为 511。
# ssl_trusted_combined_path: /usr/local/apisix/conf/cert/.ssl_trusted_combined.pem # 所有受信任证书会合并到单个文件中
ssl_trusted_certificate: system # 指定以逗号分隔的受信任 CA 列表。取值可以是 "system"(使用系统可用的 CA 证书),也可以是
# PEM 格式受信任 CA 证书的文件路径,
# 用于在 APISIX 与外部服务(例如 etcd)
# 进行 SSL/TLS 握手时验证证书
ssl_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
ssl_session_tickets: false # 默认禁用 ssl_session_tickets,因为启用它会使完全前向保密失效。
# 参考:https://github.com/mozilla/server-side-tls/issues/135

key_encrypt_salt: # 如果未设置,会将原始 SSL key 保存到 etcd。
- edd1c9f0985e76a2 # 如果设置,key_encrypt_salt 应为字符串数组,且大小也为 16;它会使用 AES-128-CBC 加密 SSL key
# !!! 保存 SSL 后不要修改它,否则无法解密已保存的 SSL key !!
# 仅使用第一个 key 加密,并按数组顺序解密。

#fallback_sni: "my.default.domain" # 如果设置,当客户端在握手期间未发送 SNI 时,将改用 fallback SNI
enable_control: true
#control:
# ip: 127.0.0.1
# port: 9090
disable_sync_configuration_during_start: false # 安全退出。功能稳定后移除此项

# 该时间用于区分 worker 是首次启动,还是崩溃后重启;单位为秒。
worker_startup_time_threshold: 60

data_encryption: # 在插件 schema 中添加 `encrypt_fields = { $field },` 以启用加密
enable: false # 如果未设置,默认值为 `false`。
keyring:
- qeddd145sfvddff3 # 如果未设置,会将原始值保存到 etcd。
# 如果设置,keyring 应为字符串数组,且大小也为 16;它会使用 AES-128-CBC 加密字段
# !!! 加密后不要修改它,否则无法解密已保存的字段 !!
# 仅使用第一个 key 加密,并按数组顺序解密。

# status: # 启用后,APISIX 会提供 `/status` 和 `/status/ready` 端点
# ip: 127.0.0.1 # 如果 APISIX 已成功启动并正常运行,/status 端点会返回 200 状态码
# port: 7085 # 如果配置的 etcd(dp_manager)均不可用,/status/ready 端点会返回 503 状态码

# disable_upstream_healthcheck: false # 健康检查的全局开关。默认为 false。
# 设置为 true 时,会覆盖所有上游健康检查配置并全局禁用健康检查。

# 微调 secret 等功能使用的 LRU 缓存参数
lru:
secret:
ttl: 300 # seconds
count: 512
neg_ttl: 60
neg_count: 512

nginx_config: # 用于渲染模板并生成 nginx.conf 的配置
#user: root # 指定 worker 进程的执行用户。
# 只有主进程以超级用户权限运行时,"user" 指令才有意义。
# 如果不是 root 用户,默认值为当前用户。
error_log: logs/error.log
error_log_level: warn # warn,error
worker_processes: auto # 如果要在容器中使用多个核心,可以通过环境变量 "APISIX_WORKER_PROCESSES" 注入 CPU 数量
enable_cpu_affinity: false # 默认禁用 CPU 亲和性;如果 APISIX 部署在物理机上,可以启用并正常工作。
worker_rlimit_nofile: 20480 # worker 进程可打开的文件数量,应大于 worker_connections
worker_shutdown_timeout: 240s # worker 进程优雅关闭的超时时间

max_pending_timers: 16384 # 如果看到 "too many pending timers" 错误,请增大该值
max_running_timers: 4096 # 如果看到 "lua_max_running_timers are not enough" 错误,请增大该值

event:
worker_connections: 10620
#envs: # 允许获取环境变量列表
# - TEST_ENV

meta:
lua_shared_dict:
prometheus-metrics: 128m

stream:
enable_access_log: false # 是否启用访问日志,默认为 false
access_log: logs/access_stream.log
access_log_format: "$remote_addr [$time_local] $protocol $status $bytes_sent $bytes_received $session_time"
# 可访问 http://nginx.org/en/docs/varindex.html 创建自定义日志格式
access_log_format_escape: default # 允许在变量中设置 json 或 default 字符转义
lua_shared_dict:
etcd-cluster-health-check-stream: 10m
lrucache-lock-stream: 10m
plugin-limit-conn-stream: 10m
worker-events-stream: 10m
tars-stream: 1m
config-stream: 5m

# 由于用户可以在 snippet 中添加任意配置,
# 用户需要自行检查配置
# 是否与 APISIX 冲突。
main_configuration_snippet: |
# 将自定义 Nginx main 配置添加到 nginx.conf。
# 配置应保持良好缩进!
http_configuration_snippet: |
# 将自定义 Nginx http 配置添加到 nginx.conf。
# 配置应保持良好缩进!
http_server_configuration_snippet: |
# 将自定义 Nginx http server 配置添加到 nginx.conf。
# 配置应保持良好缩进!
http_server_location_configuration_snippet: |
# 将自定义 Nginx http server location 配置添加到 nginx.conf。
# 配置应保持良好缩进!
http_admin_configuration_snippet: |
# 将自定义 Nginx admin server 配置添加到 nginx.conf。
# 配置应保持良好缩进!
http_end_configuration_snippet: |
# 将自定义 Nginx http end 配置添加到 nginx.conf。
# 配置应保持良好缩进!
stream_configuration_snippet: |
# 将自定义 Nginx stream 配置添加到 nginx.conf。
# 配置应保持良好缩进!

http:
enable_access_log: true # 是否启用访问日志,默认为 true
access_log: logs/access.log
# 可用变量:
# request_type: traditional_http / ai_chat / ai_stream
# llm_time_to_first_token: 从开始向 AI 服务器发送请求到收到首个 Token 的时长
# llm_prompt_tokens: 提示词 Token 数量
# llm_completion_tokens: 聊天补全中的 Token 数量
# llm_total_tokens: 使用的 Token 总数,包括提示词 Token 和补全 Token
# llm_stream: 请求是否为流式请求
# llm_has_tool_calls: LLM 响应是否包含工具调用
# llm_tool_count: 请求中提供的工具数量
# llm_end_user_id: 从请求正文中提取的最终用户标识符
# llm_cache_read_input_tokens: 从提供商提示词缓存中读取的提示词 Token 数量
# llm_cache_creation_input_tokens: 写入提供商提示词缓存的提示词 Token 数量
# llm_reasoning_tokens: 推理模型使用的推理 Token 数量
access_log_format: "$remote_addr - $remote_user [$time_local] $http_host \"$request_line\" $status $body_bytes_sent $request_time \"$http_referer\" \"$http_user_agent\" $upstream_addr $upstream_status $upstream_response_time \"$upstream_scheme://$upstream_host$upstream_uri\" \"$apisix_request_id\""
access_log_format_escape: default # 允许在变量中设置 json 或 default 字符转义
keepalive_timeout: 60s # keep-alive 客户端连接在服务端保持打开的超时时间。
client_header_timeout: 60s # 读取客户端请求头的超时时间,超时后向客户端返回 408 (Request Time-out) 错误
client_body_timeout: 60s # 读取客户端请求正文的超时时间,超时后向客户端返回 408 (Request Time-out) 错误
client_max_body_size: 0 # 允许的客户端请求正文最大大小。
# 如果超过该值,会向客户端返回 413 (Request Entity Too Large) 错误。
# 注意,与 Nginx 不同,默认情况下我们不限制正文大小。

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_header
real_ip_recursive: "off" # http://nginx.org/en/docs/http/ngx_http_realip_module.html#real_ip_recursive
real_ip_from: # http://nginx.org/en/docs/http/ngx_http_realip_module.html#set_real_ip_from
- 127.0.0.1
- "unix:"
custom_lua_shared_dict: # 向 nginx.conf 添加自定义共享缓存
# ipc_shared_dict: 100m # 自定义共享缓存,格式为 `cache-key: cache-size`
config: 5m
kubernetes: 64m
nacos: 64m
consul: 64m

# 与被代理的 HTTPS 服务器建立连接时,
# 启用或禁用通过 TLS Server Name Indication 扩展(SNI,RFC 6066)传递服务器名称。
proxy_ssl_server_name: true
upstream:
keepalive: 320 # 设置每个 worker 进程缓存中保留的到上游服务器的最大空闲 keepalive 连接数。
# 超过该数量时,将关闭最近最少使用的连接。
keepalive_requests: 1000 # 设置一个 keepalive 连接可以处理的最大请求数。
# 达到最大请求数后,连接会关闭。
keepalive_timeout: 60s # 设置到上游服务器的空闲 keepalive 连接保持打开的超时时间。
charset: utf-8 # 将指定字符集添加到 "Content-Type" 响应头字段中,参见
# http://nginx.org/en/docs/http/ngx_http_charset_module.html#charset
variables_hash_max_size: 2048 # 设置变量哈希表的最大大小。

lua_shared_dict:
internal-status: 10m
plugin-limit-req: 10m
plugin-limit-count: 10m
plugin-limit-conn: 10m
plugin-limit-conn-redis-cluster-slot-lock: 1m
plugin-graphql-limit-count: 10m
plugin-graphql-limit-count-reset-header: 10m
plugin-ai-rate-limiting: 10m
plugin-ai-rate-limiting-reset-header: 10m
upstream-healthcheck: 10m
worker-events: 10m
lrucache-lock: 10m
balancer-ewma: 10m
balancer-ewma-locks: 10m
balancer-ewma-last-touched-at: 10m
plugin-limit-req-redis-cluster-slot-lock: 1m
plugin-limit-count-redis-cluster-slot-lock: 1m
plugin-limit-count-advanced: 10m
plugin-limit-count-advanced-redis-cluster-slot-lock: 1m
tracing_buffer: 32m
plugin-api-breaker: 10m
etcd-cluster-health-check: 10m
discovery: 1m
jwks: 1m
introspection: 10m
access-tokens: 1m
ext-plugin: 1m
tars: 1m
cas-auth: 10m
saml_sessions: 10m
status_report: 1m

#discovery: # 服务发现中心
# dns:
# servers:
# - "127.0.0.1:8600" # 使用你的 DNS 服务器真实地址
# order: # 解析时尝试不同 DNS 记录类型的顺序
# - last # "last" 会尝试该主机名上一次成功使用的类型。
# - SRV
# - A
# - AAAA
# - CNAME
# eureka:
# host: # 可以定义同一 eureka 集群的多个 eureka 主机地址。
# - "http://127.0.0.1:8761"
# prefix: /eureka/
# fetch_interval: 30 # 默认为 30s
# weight: 100 # 节点默认权重
# timeout:
# connect: 2000 # 默认为 2000ms
# send: 2000 # 默认为 2000ms
# read: 5000 # 默认为 5000ms
# nacos:
# host:
# - "http://${username}:${password}@${host1}:${port1}"
# prefix: "/nacos/v1/"
# fetch_interval: 30 # 默认为 30 秒
# weight: 100 # 默认为 100
# timeout:
# connect: 2000 # 默认为 2000 ms
# send: 2000 # 默认为 2000 ms
# read: 5000 # 默认为 5000 ms
# consul_kv:
# servers:
# - "http://127.0.0.1:8500"
# - "http://127.0.0.1:8600"
# prefix: "upstreams"
# skip_keys: # 如果需要跳过特定 key
# - "upstreams/unused_api/"
# timeout:
# connect: 2000 # 默认为 2000 ms
# read: 2000 # 默认为 2000 ms
# wait: 60 # 默认为 60 秒
# weight: 1 # 默认为 1
# fetch_interval: 3 # 默认为 3 秒,仅在 keepalive: false 方式下生效
# keepalive: true # 默认为 true,使用长轮询方式查询 consul 服务器
# sort_type: "origin" # 默认为 origin
# default_server: # 未命中时可以定义默认服务器
# host: "127.0.0.1"
# port: 20999
# metadata:
# fail_timeout: 1 # 默认为 1 ms
# weight: 1 # 默认为 1
# max_fails: 1 # 默认为 1
# dump: # 如有需要,注册节点更新时可以转储到文件
# path: "logs/consul_kv.dump"
# expire: 2592000 # 单位为秒,此处为 30 天
# consul:
# servers: # 确保这些 consul 服务器中的服务名称唯一
# - "http://127.0.0.1:8500" # `http://127.0.0.1:8500` 和 `http://127.0.0.1:8600` 是不同集群
# - "http://127.0.0.1:8600"
# skip_services: # 如果需要跳过特定服务
# - "service_a" # `consul` 服务是默认跳过服务
# timeout:
# connect: 2000 # 默认为 2000 ms
# read: 2000 # 默认为 2000 ms
# wait: 60 # 默认为 60 秒
# weight: 1 # 默认为 1
# fetch_interval: 3 # 默认为 3 秒,仅在 keepalive: false 方式下生效
# keepalive: true # 默认为 true,使用长轮询方式查询 consul 服务器
# default_service: # 未命中时可以定义默认服务器
# host: "127.0.0.1"
# port: 20999
# metadata:
# fail_timeout: 1 # 默认为 1 ms
# weight: 1 # 默认为 1
# max_fails: 1 # 默认为 1
# dump: # 如有需要,注册节点更新时可以转储到文件
# path: "logs/consul.dump"
# expire: 2592000 # 单位为秒,此处为 30 天
# load_on_init: true # 默认为 true,初始化时加载 consul 转储文件
# kubernetes:
# ### Kubernetes 服务发现同时支持单集群和多集群模式
# ### 适用于服务分布在单个或多个 Kubernetes 集群中的场景。
#
# ### 单集群模式 ###
# service:
# schema: https # apiserver 协议,可选值 [http, https],默认为 https
# host: ${KUBERNETES_SERVICE_HOST} # apiserver 主机,可选值 [ipv4, ipv6, domain, environment variable],默认为 ${KUBERNETES_SERVICE_HOST}
# port: ${KUBERNETES_SERVICE_PORT} # apiserver 端口,可选值 [端口号, 环境变量],默认为 ${KUBERNETES_SERVICE_PORT}
# client:
# # serviceaccount token 或 serviceaccount token_file 路径
# token_file: ${KUBERNETES_CLIENT_TOKEN_FILE}
# # token: |-
# # eyJhbGciOiJSUzI1NiIsImtpZCI6Ikx5ME1DNWdnbmhQNkZCNlZYMXBsT3pYU3BBS2swYzBPSkN3ZnBESGpkUEEif
# # 6Ikx5ME1DNWdnbmhQNkZCNlZYMXBsT3pYU3BBS2swYzBPSkN3ZnBESGpkUEEifeyJhbGciOiJSUzI1NiIsImtpZCI
# # Kubernetes 服务发现插件支持使用 namespace_selector
# # 可以使用 [equal, not_equal, match, not_match] 之一过滤命名空间
# namespace_selector:
# # 仅保存命名空间等于 default 的端点
# equal: default
# # 仅保存命名空间不等于 default 的端点
# #not_equal: default
# # 仅保存命名空间匹配 [default, ^my-[a-z]+$] 之一的端点
# #match:
# #- default
# #- ^my-[a-z]+$
# # 仅保存命名空间不匹配 [default, ^my-[a-z]+$] 之一的端点
# #not_match:
# #- default
# #- ^my-[a-z]+$
# # Kubernetes 服务发现插件支持使用 label_selector
# # label_selector 表达式请参见 https://kubernetes.io/docs/concepts/overview/working-with-objects/labels
# label_selector: |-
# first="a",second="b"
# # 预留 Lua 共享内存大小,1m 内存约可存储 1000 个端点
# shared_size: 1m # 默认为 1m
# ### 单集群模式 ###
#
# ### 多集群模式 ###
# - id: release # 指向集群的自定义名称,模式为 ^[a-z0-9]{1,8}
# service:
# schema: https # apiserver 协议,可选值 [http, https],默认为 https
# host: ${KUBERNETES_SERVICE_HOST} # apiserver 主机,可选值 [ipv4, ipv6, domain, environment variable]
# port: ${KUBERNETES_SERVICE_PORT} # apiserver 端口,可选值 [端口号, 环境变量]
# client:
# # serviceaccount token 或 serviceaccount token_file 路径
# token_file: ${KUBERNETES_CLIENT_TOKEN_FILE}
# # token: |-
# # eyJhbGciOiJSUzI1NiIsImtpZCI6Ikx5ME1DNWdnbmhQNkZCNlZYMXBsT3pYU3BBS2swYzBPSkN3ZnBESGpkUEEif
# # 6Ikx5ME1DNWdnbmhQNkZCNlZYMXBsT3pYU3BBS2swYzBPSkN3ZnBESGpkUEEifeyJhbGciOiJSUzI1NiIsImtpZCI
# # Kubernetes 服务发现插件支持使用 namespace_selector
# # 可以使用 [equal, not_equal, match, not_match] 之一过滤命名空间
# namespace_selector:
# # 仅保存命名空间等于 default 的端点
# equal: default
# # 仅保存命名空间不等于 default 的端点
# #not_equal: default
# # 仅保存命名空间匹配 [default, ^my-[a-z]+$] 之一的端点
# #match:
# #- default
# #- ^my-[a-z]+$
# # 仅保存命名空间不匹配 [default, ^my-[a-z]+$] 之一的端点
# #not_match:
# #- default
# #- ^my-[a-z]+$
# # Kubernetes 服务发现插件支持使用 label_selector
# # label_selector 表达式请参见 https://kubernetes.io/docs/concepts/overview/working-with-objects/labels
# label_selector: |-
# first="a",second="b"
# # 预留 Lua 共享内存大小,1m 内存约可存储 1000 个端点
# shared_size: 1m # 默认为 1m
# ### 多集群模式 ###

graphql:
max_size: 1048576 # GraphQL 的最大大小限制,单位为字节,默认为 1MiB

#ext-plugin:
#cmd: ["ls", "-l"]

plugins: # 插件列表(按优先级排序)
# - exit-transformer # priority: 9999999
- real-ip # priority: 23000
# - toolset # priority: 22901
- ai # priority: 22900
- client-control # priority: 22000
- proxy-buffering # priority: 21991
- proxy-control # priority: 21990
- 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
- portal-auth # priority: 2750
- chaitin-waf # priority: 2700
- multi-auth # priority: 2600
- openid-connect # priority: 2599
- saml-auth # priority: 2598
- 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
- key-auth # priority: 2500
- acl # priority: 2410
- consumer-restriction # priority: 2400
- attach-consumer-label # priority: 2399
- forward-auth # priority: 2002
- opa # priority: 2001
- authz-keycloak # priority: 2000
- data-mask # priority: 1500
#- error-log-logger # priority: 1091
- proxy-cache # priority: 1085
- body-transformer # priority: 1080
- ai-request-rewrite # priority: 1073
- ai-prompt-template # priority: 1071
- ai-prompt-decorator # priority: 1070
- ai-prompt-guard # priority: 1072
- ai-rag # priority: 1060
- ai-aws-content-moderation # priority: 1050
- ai-proxy-multi # priority: 1041
- ai-proxy # priority: 1040
- ai-rate-limiting # priority: 1030
- ai-aliyun-content-moderation # priority: 1029
- proxy-mirror # priority: 1010
- graphql-proxy-cache # priority: 1009
- proxy-rewrite # priority: 1008
- workflow # priority: 1006
- api-breaker # priority: 1005
- graphql-limit-count # priority: 1004
- limit-conn # priority: 1003
- limit-count # priority: 1002
- limit-count-advanced # priority: 1001
- limit-req # priority: 999
#- node-status # priority: 998
- traffic-label # priority: 995
- gzip # priority: 994
- server-info # priority: 990
- api7-traffic-split # priority: 966
- traffic-split # priority: 966
- redirect # priority: 900
- response-rewrite # priority: 899
- soap # priority: 554
- openapi-to-mcp # priority: 540
- oas-validator # priority: 510
- 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
- lago # priority: 415
- error-page # priority: 450
- 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
#- log-rotate # priority: 100
# <- 建议你的自定义插件使用优先级 (0, 100)
- 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: # 按优先级排序
- ip-restriction # priority: 3000
- limit-conn # priority: 1003
- mqtt-proxy # priority: 1000
- traffic-split # priority: 966
#- prometheus # priority: 500
- syslog # priority: 401
# <- 建议你的自定义插件使用优先级 (0, 100)

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

#xrpc:
#protocols:
#- name: pingpong

plugin_attr:
log-rotate:
enable: false
timeout: 10000 # 日志轮转的最长等待时间(单位:毫秒)
interval: 3600 # 轮转间隔(单位:秒)
max_kept: 168 # 保留的最大日志文件数
max_size: -1 # 待轮转日志文件的最大字节数,小于 0 时跳过大小检查
enable_compression: false # 是否启用日志文件压缩(gzip),默认为 false
skywalking:
service_name: APISIX
service_instance_name: APISIX Instance Name
endpoint_addr: http://127.0.0.1:12800
soap:
endpoint: http://127.0.0.1:5000
timeout: 3000
openapi-to-mcp:
port: 3000 # OpenAPI-to-MCP 服务在 127.0.0.1 上监听的端口
prometheus:
export_uri: /apisix/prometheus/metrics
metric_prefix: apisix_
enable_export_server: true
export_addr:
ip: 127.0.0.1
port: 9091
fetch_metric_timeout: 5
allow_degradation: false
degradation_pause_steps: [ 60 ]
#metrics:
# http_status:
# # 来自 nginx 变量的额外标签
# extra_labels:
# # 标签名不需要与变量名相同
# # 以下标签仅为示例,你可以按需添加任何有效变量
# - upstream_addr: $upstream_addr
# - upstream_status: $upstream_status
# expire: 0 # 指标被移除前的过期时间,单位为秒。
# # 0 表示指标不会过期
# http_latency:
# extra_labels:
# - upstream_addr: $upstream_addr
# expire: 0 # 指标被移除前的过期时间,单位为秒。
# # 0 表示指标不会过期
# bandwidth:
# extra_labels:
# - upstream_addr: $upstream_addr
# expire: 0 # 指标被移除前的过期时间,单位为秒。
# # 0 表示指标不会过期
# default_buckets:
# - 10
# - 50
# - 100
# - 200
# - 500
# llm_latency_buckets: # apisix_llm_latency 直方图的 buckets(单位:毫秒)
# # 自 3.9.14 起,同时适用于 type=total 和 type=ttft
# - 100
# - 500
# - 1000
# - 5000
# llm_prompt_tokens_buckets: # apisix_llm_prompt_tokens_dist 直方图的 buckets(单位:Token)
# - 100
# - 1000
# - 10000
# llm_completion_tokens_buckets: # apisix_llm_completion_tokens_dist 直方图的 buckets(单位:Token)
# - 100
# - 1000
# - 10000
server-info:
report_ttl: 60 # etcd 中服务器信息的存活时间(单位:秒)
dubbo-proxy:
upstream_multiplex_count: 32
proxy-mirror:
timeout: # 镜像子请求中的代理超时时间
connect: 60s
read: 60s
send: 60s
# redirect:
# https_port: 8443 # HTTP 重定向到 HTTPS 使用的默认端口
inspect:
delay: 3 # 单位为秒
hooks_file: "/usr/local/apisix/plugin_inspect_hooks.lua"
zipkin: # 插件:zipkin
set_ngx_var: false # 将 zipkin 变量导出为 nginx 变量

deployment:
role: traditional
role_traditional:
config_provider: etcd
admin:
# 使用 API 调用 Admin API 时的默认 Token。
# *注意*:强烈建议修改该值以保护 APISIX Admin API。
# 禁用该配置项表示 Admin API
# 不需要任何认证。
admin_key:
-
name: admin
key: edd1c9f034335f136f87ad84b625c8f1
role: admin # admin:管理所有配置数据
# viewer:只能查看配置数据
-
name: viewer
key: 4054f7cf07e344346cd3f287985e76a2
role: viewer

enable_admin_cors: true # Admin API 支持 CORS 响应头。
allow_admin: # http://nginx.org/en/docs/http/ngx_http_access_module.html#allow
- 127.0.0.0/24 # 如果未设置任何 IP 列表,则默认允许任意 IP 访问。
#- "::/64"
admin_listen: # 使用独立端口
ip: 0.0.0.0 # 指定 IP。如果未设置,默认值为 `0.0.0.0`。
port: 9180 # 指定端口,必须与 node_listen 的端口不同。

#https_admin: true # 使用独立端口访问 Admin API 时启用 HTTPS。
# Admin API 会使用 conf/apisix_admin_api.crt 和 conf/apisix_admin_api.key 作为证书。

admin_api_mtls: # 依赖 `admin_listen` 和 `https_admin`。
admin_ssl_cert: "" # 自签名服务端证书的路径。
admin_ssl_cert_key: "" # 自签名服务端密钥的路径。
admin_ssl_ca_cert: "" # 自签名 CA 证书的路径。该 CA 用于签发所有 Admin API 调用方证书。

admin_api_version: v3 # Admin API 版本,最新版本为 v3。

# fallback_cp:
# mode: "write" # "write" 表示 DP 实例将在备份模式下运行,并且不接受/代理任何请求。默认为 "write",即指定 "fallback" 模式
# interval: 1 # 备份模式的间隔,单位为秒
# aws_s3: # AWS S3 配置,用于存储配置/资源,可在备份模式下推送,也可在 fallback 模式下拉取
# access_key: "just-access"
# secret_key: "super-secret"
# resource_bucket: "resource_bucket"
# config_bucket: "config_bucket"
# region: "ap-south-1"
# endpoint: "http://localhost:6969"
# azure_blob: # Azure Blob Storage 配置,用于存储配置/资源,可在备份模式下推送,也可在 fallback 模式下拉取
# account_name: devstoreaccount1
# account_key: "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="
# resource_container: yaml
# config_container: config
# endpoint: "http://localhost:10000/devstoreaccount1"

etcd:
host: # 可以定义同一 etcd 集群的多个 etcd 主机地址。
- "http://127.0.0.1:2379" # 多个 etcd 地址。如果你的 etcd 集群启用了 TLS,请使用 https 协议,
# 例如 https://127.0.0.1:2379。
prefix: /apisix # etcd 中的配置前缀
timeout: 30 # 连接/读取/写入 etcd 的超时时间。
watch_timeout: 50 # 监听 etcd 的超时时间
#resync_delay: 5 # 同步失败且需要重试时,在配置秒数外加 50% 随机抖动后重新同步
#health_check_timeout: 10 # etcd 在配置秒数后重试不健康节点
startup_retry: 2 # 启动期间重试 etcd 的次数,默认为 2
#user: root # etcd 的 root 用户名
#password: 5tHkHhYkjr6cQY # etcd 的 root 密码
tls:
# 要启用 etcd 客户端证书,需要构建 APISIX-Base,参见
# https://apisix.apache.org/docs/apisix/FAQ#how-do-i-build-the-apisix-base-environment
#cert: /path/to/cert # etcd 客户端使用的证书路径
#key: /path/to/key # etcd 客户端使用的 key 路径

verify: true # 与 etcd 建立 TLS 连接时是否验证 etcd 端点证书,
# 默认值为 true,即严格验证证书。
#sni: # etcd TLS 请求的 SNI。如果缺失,将使用 URL 的 host 部分。

api7ee:
telemetry:
enable: true # 启用向控制面上报遥测数据
interval: 15 # 向控制面发送遥测数据的间隔,单位为秒
max_metrics_size: 33554432 # 发送到控制面的指标数据最大大小,单位为字节(32M);如果超出该大小,数据会被截断
metrics_batch_size: 4194304 # 压缩前的最大批量大小(字节,4 MiB)。
compression_level: -1 # gzip 压缩级别。-1 使用库默认值(通常为 6)。
# 范围 0-9;1 表示最快,9 表示最高压缩率。默认启用 Gzip。
healthcheck_report_interval: 120 # 健康检查数据上报间隔,单位为秒
http_timeout: 30s # 向控制面发送健康检查和遥测数据时使用的 HTTP 超时时间
consumer_proxy:
enable: false # 如果 enable 为 true,消费者资源将由控制面代理。
cache_success_count: 512 # 缓存从控制面查询到的成功结果数量。
cache_success_ttl: 60 # 缓存从控制面查询到的成功结果 TTL(单位:秒)。
cache_failure_count: 512 # 缓存从控制面查询到的失败结果数量。
cache_failure_ttl: 60 # 缓存从控制面查询到的失败结果 TTL(单位:秒)。
developer_proxy: # 代理 portal-auth 插件
cache_success_count: 256 # 缓存从控制面查询到的成功结果数量。
cache_success_ttl: 15 # 缓存从控制面查询到的成功结果 TTL(单位:秒)。
cache_failure_count: 256 # 缓存从控制面查询到的失败结果数量。
cache_failure_ttl: 15 # 缓存从控制面查询到的失败结果 TTL(单位:秒)。