diff --git a/apisix/upstream.lua b/apisix/upstream.lua index f41364162f5a6..45f244161e98f 100644 --- a/apisix/upstream.lua +++ b/apisix/upstream.lua @@ -134,10 +134,13 @@ local function create_checker(upstream) local host = upstream.checks and upstream.checks.active and upstream.checks.active.host local port = upstream.checks and upstream.checks.active and upstream.checks.active.port - local up_hdr = upstream.pass_host == "rewrite" and upstream.upstream_host - local use_node_hdr = upstream.pass_host == "node" for _, node in ipairs(upstream.nodes) do - local host_hdr = up_hdr or (use_node_hdr and node.domain) + local host_hdr + if upstream.pass_host == "rewrite" and upstream.upstream_host then + host_hdr = upstream.upstream_host + elseif upstream.pass_host == "node" and node.domain then + host_hdr = node.domain + end local ok, err = checker:add_target(node.host, port or node.port, host, true, host_hdr) if not ok then