This is an automated email from the ASF dual-hosted git repository.

baoyuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
     new 2667da12c feat(eureka): allow domain named nodes (#12993)
2667da12c is described below

commit 2667da12c22b3f5fc70cf33b6ad81a1529840d9e
Author: Shreemaan Abhishek <[email protected]>
AuthorDate: Wed Feb 11 08:46:53 2026 +0545

    feat(eureka): allow domain named nodes (#12993)
---
 apisix/discovery/eureka/init.lua | 15 +++++++++++----
 ci/pod/eureka/env/common.env     |  2 +-
 t/discovery/eureka.t             | 32 ++++++++++++++++++++++++++++++++
 3 files changed, 44 insertions(+), 5 deletions(-)

diff --git a/apisix/discovery/eureka/init.lua b/apisix/discovery/eureka/init.lua
index 2625524d9..ff7c8fe23 100644
--- a/apisix/discovery/eureka/init.lua
+++ b/apisix/discovery/eureka/init.lua
@@ -135,9 +135,15 @@ local function parse_instance(instance)
     local ip = instance.ipAddr
     if not ipmatcher.parse_ipv4(ip) and
             not ipmatcher.parse_ipv6(ip) then
-        log.error(instance.app, " service ", instance.hostName, " node IP ", 
ip,
-                " is invalid(must be IPv4 or IPv6).")
-        return
+        log.info(instance.app, " service ", instance.hostName, " node IP ", ip,
+                " is not an IP, trying to resolve it.")
+        local ip_info, err = core.resolver.parse_domain(ip)
+        if ip_info then
+            return ip_info, port, instance.metadata, ip
+        else
+            log.error("failed to resolve ", ip, ": ", err)
+            return
+        end
     end
     return ip, port, instance.metadata
 end
@@ -185,7 +191,7 @@ local function fetch_full_registry(premature)
     local up_apps = core.table.new(0, #apps)
     for _, app in ipairs(apps) do
         for _, instance in ipairs(app.instance) do
-            local ip, port, metadata = parse_instance(instance)
+            local ip, port, metadata, domain = parse_instance(instance)
             if ip and port then
                 local nodes = up_apps[app.name]
                 if not nodes then
@@ -197,6 +203,7 @@ local function fetch_full_registry(premature)
                     port = port,
                     weight = metadata and metadata.weight or default_weight,
                     metadata = metadata,
+                    domain = domain,
                 })
                 if metadata then
                     -- remove useless data
diff --git a/ci/pod/eureka/env/common.env b/ci/pod/eureka/env/common.env
index 11169cb1b..98a4caf39 100644
--- a/ci/pod/eureka/env/common.env
+++ b/ci/pod/eureka/env/common.env
@@ -1,7 +1,7 @@
 ENVIRONMENT=apisix
 spring.application.name=apisix-eureka
 server.port=8761
-eureka.instance.ip-address=127.0.0.1
+eureka.instance.ip-address=localhost
 eureka.client.registerWithEureka=true
 eureka.client.fetchRegistry=false
 eureka.client.serviceUrl.defaultZone=http://127.0.0.1:8761/eureka/
diff --git a/t/discovery/eureka.t b/t/discovery/eureka.t
index da76912d3..f87272675 100644
--- a/t/discovery/eureka.t
+++ b/t/discovery/eureka.t
@@ -165,3 +165,35 @@ successfully updated service registry
 --- no_error_log
 failed to fetch registry from all eureka hosts
 failed to fetch registry from http://127.0.0.1:8761/eureka/
+
+
+
+=== TEST 5: verify host header with pass_host: node
+--- yaml_config eval: $::yaml_config
+--- apisix_yaml
+routes:
+  -
+    uri: /eureka/*
+    upstream:
+      service_name: APISIX-EUREKA
+      discovery_type: eureka
+      type: roundrobin
+      pass_host: node
+    plugins:
+        serverless-post-function:
+            phase: log
+            functions:
+                - "return function(conf, ctx)
+                    local core = require('apisix.core')
+                    core.log.warn('upstream_host: ', ctx.var.upstream_host)
+                    core.log.warn('upstream_addr: ', ctx.var.upstream_addr)
+                  end"
+
+#END
+--- request
+GET /eureka/apps/APISIX-EUREKA
+--- response_body_like
+.*<name>APISIX-EUREKA</name>.*
+--- error_log
+upstream_host: localhost
+upstream_addr: 127.0.0.1

Reply via email to