mirror of
https://gitee.com/iresty/apisix.git
synced 2024-12-11 09:43:49 +08:00
bugfix: failed to set server peer when upstreams.node is address in apisix.yaml (#1824)
Fix #1798
This commit is contained in:
parent
e598e6fa6a
commit
54abe58315
@ -311,7 +311,7 @@ end
|
||||
|
||||
|
||||
function _M.fetch_created_obj(key)
|
||||
return created_obj[key]
|
||||
return created_obj[sub_str(key, 2)]
|
||||
end
|
||||
|
||||
|
||||
|
@ -313,9 +313,14 @@ function _M.http_access_phase()
|
||||
local enable_websocket
|
||||
local up_id = route.value.upstream_id
|
||||
if up_id then
|
||||
local upstreams_etcd = core.config.fetch_created_obj("/upstreams")
|
||||
if upstreams_etcd then
|
||||
local upstream = upstreams_etcd:get(tostring(up_id))
|
||||
local upstreams = core.config.fetch_created_obj("/upstreams")
|
||||
if upstreams then
|
||||
local upstream = upstreams:get(tostring(up_id))
|
||||
if not upstream then
|
||||
core.log.error("failed to find upstream by id: " .. up_id)
|
||||
return core.response.exit(500)
|
||||
end
|
||||
|
||||
if upstream.has_domain then
|
||||
local _, err = parsed_domain(upstream, api_ctx.conf_version,
|
||||
parse_domain_in_up, upstream)
|
||||
|
@ -139,3 +139,25 @@ GET /hello
|
||||
hello world
|
||||
--- no_error_log
|
||||
[error]
|
||||
|
||||
|
||||
|
||||
=== TEST 5: upstream domain
|
||||
--- yaml_config eval: $::yaml_config
|
||||
--- apisix_yaml
|
||||
routes:
|
||||
-
|
||||
uri: /get
|
||||
upstream_id: 1
|
||||
upstreams:
|
||||
-
|
||||
id: 1
|
||||
nodes:
|
||||
"httpbin.org:80": 1
|
||||
type: roundrobin
|
||||
#END
|
||||
--- request
|
||||
GET /get
|
||||
--- error_code: 200
|
||||
--- no_error_log
|
||||
[error]
|
||||
|
Loading…
Reference in New Issue
Block a user