配置相关
以下配置均为 APISIX 默认配置。
config-default.yaml
# dns_resolver: # If not set, read from `/etc/resolv.conf`
# - 1.1.1.1
# - 8.8.8.8
dns_resolver_valid: 30 # valid time for dns result 30 seconds
resolver_timeout: 5 # resolver timeout
nginx.conf
nginx.conf
根据 config-default.yaml
配置文件生成。
init_by_lua_block {
require "resty.core"
apisix = require("apisix")
local dns_resolver = { "183.60.83.19", "183.60.82.98", }
local args = {
dns_resolver = dns_resolver,
}
apisix.http_init(args)
}
配置解析
代码
require "resty.core"
说明
这里显示引用
lua-resy-core
是因为lua-resty-core
把lua-nginx-module
中的部分 API 使用 FFI 方式实现,FFI 方式实现的代码可以被 JIT 追踪和优化,性能更高当前 Openresty 版本是默认使用
lua-resty-core
,可通过以下方法验证 Openresty 版本是否默认使用lua-resty-core
nginx.conf 未显示指定
require "resty.core"
将环境中的 resty.core 重命名为 resty.core.1
mv /usr/local/openresty/lualib/resty/core.lua /usr/local/openresty/lualib/resty/core.lua.1
启动 openresty ,显示以下错误:
nginx: