upsync_dump_path
指定用于转储上游服务器配置的文件路径。
NGINX module for syncing upstreams from consul or etcd
·
upstream
语法upsync_dump_path path;
默认值none
上下文upstream
参数1
说明
upsync_dump_path 指令用于 NGINX 的 upstream 块上下文中,用于从外部服务(如 Consul 或 etcd)配置上游服务器的同步。当通过定义的同步机制动态修改上游服务器时,当前的服务器配置会自动转储到文件系统中指定的路径。这便于更轻松地管理和审计上游服务器设置,而无需重新加载整个 NGINX 配置。如果设置了该参数,每当检测到上游服务器配置发生变化时,NGINX 会将配置写到指定的文件路径,确保最新的服务器设置被准确记录并可用于将来参考或调试。
upsync_dump_path 的参数是一个字符串,表示要保存配置的文件路径。重要的是,NGINX 工作进程必须具有向该指定路径写入的权限,以便能够成功创建或覆盖该位置的配置文件。文件权限配置不当可能导致错误或更新失败,从而导致服务器配置过时并可能出现停机。
配置示例
http {
upstream backend {
upsync 127.0.0.1:8500/v1/kv/upstreams/test/ upsync_timeout=6m upsync_interval=500ms;
upsync_dump_path /usr/local/nginx/conf/servers/servers_test.conf;
include /usr/local/nginx/conf/servers/servers_test.conf;
}
server {
listen 80;
location / {
proxy_pass http://backend;
}
}
}⚠
确保 NGINX worker process 对指定的 file path 具有 write permissions。
⚠
如果指定的 path 不存在,NGINX 将无法 dump the configuration,除非它能 create the file;请确保 parent directory 已存在。
⚠
如果未正确管理,对该文件的反复更新可能导致 file descriptor exhaustion。