Hi.
I’m new to Apache Apisix and looking into the documentation, but still I
cannot solve the following issue I’m encountering when I configure
upstreams with multiple nodes. Specifically, when I use the default
“pass_host = pass” to route traffic to the nodes of an upstream, HTTP
requests get responses with 4XX or 5XX status code. My configuration is
as minimal as:
{
"nodes": [
{
"host": "webservice1",
"port": xxx,
"weight": 1
},
{
"host": "webservice2",
"port": xxx,
"weight": 1
}
],
"timeout": {
"connect": 6,
"send": 6,
"read": 30
},
"type": "roundrobin",
"scheme": "https",
"pass_host": "pass",
"keepalive_pool": {
"idle_timeout": 60,
"requests": 1000,
"size": 320
}
}
These webservices reside on two different external servers and respond
with a 200 status code if directly queried.
I have the same issue when the upstream has a single node, but in that
case I simply set “pass_host = node” and everything works fine.
Unfortunately, I cannot use “node” in the case of multiple nodes (the
dashboard doesn’t permit me), even though I found examples on the
official documentation where it seems possible. I know that with
“pass_host=pass” Apisix passes transparently the request’s hosts to the
upstream, but I am not sure I completely understand what this means. To
bypass this, I tried to configure the proxy-rewrite plugin on the
corresponding route, but I can set only one single host and my upstream
have at least two nodes with different hosts. What am I missing?
It seems to me that hosts' headers are not handled properly, are they?
Here is what access.log shows:
- with a single node (host: webservice1) and pass_host = pass
xxx.xxx.xxx.xxx - - [17/Mar/2025:16:11:29 +0100] api-gw "GET / HTTP/1.1"
503 2515 0.063 "-" "curl/8.12.1" yyy.yyy.yyy.yyy 503 0.060 "https://api-gw/"
- with a single node (host: webservice1) and pass_host = node or
configuring proxy-rewrite on the route
xxx.xxx.xxx.xxx - - [17/Mar/2025:16:12:34 +0100] api-gw "GET / HTTP/1.1"
200 85 0.088 "-" "curl/8.12.1" yyy.yyy.yyy.yyy 200 0.062
"https://webservice1/"
I would really appreciate any advice or any hint to solve this issue,
because I have to deal with upstreams with multiple nodes.
Environment
• APISIX version: 3.10.0
• Operating system: Linux
• OpenResty / Nginx version: openresty/1.25.3.2
• APISIX Dashboard version: 3.0.1
• etcd_version: 3.4.0