I’m facing an issue with my Apache APISIX setup in a Docker container. I have configured a route in APISIX, but when I make a request, I get a 404 error. Here are the details of my setup:
Route Configuration:
{
"list": [
{
"createdIndex": 30,
"value": {
"host": "10.1.10.112",
"upstream": {
"pass_host": "pass",
"keepalive_pool": {
"idle_timeout": 60,
"size": 320,
"requests": 1000
},
"type": "roundrobin",
"timeout": {
"connect": 6,
"send": 6,
"read": 6
},
"scheme": "http",
"hash_on": "vars",
"nodes": {
"172.26.50.10:7011": 1
}
},
"name": "local-ords",
"priority": 100,
"status": 1,
"uri": "/api/cnam/test/18",
"update_time": 1738257518,
"create_time": 1738250330,
"id": "5497616673915544",
"methods": [
"GET",
"POST",
"PUT",
"DELETE",
"PATCH",
"HEAD",
"OPTIONS",
"CONNECT",
"TRACE",
"PURGE"
]
},
"modifiedIndex": 68,
"key": "/apisix/routes/5497616673915544"
}
],
"total": 1
}
The request URL is: http://<apisix_host>/api/cnam/test/18
The backend service at 172.26.50.10:7011
works fine when tested directly with cURL, i.e.: curl http://172.26.50.10:7011/api/cnam/test/18
.
However, when I send the request through APISIX, I always get a 404 error.
Double-checking the route configuration in APISIX and making sure it matches the expected path.
Ensuring that the upstream is correctly configured (I verified that 172.26.50.10:7011
is reachable from within the container).
Checking logs for any errors or warnings that might provide more information about the issue.
Apache APISIX Docker container Using a reverse proxy with APISIX to route requests to a backend service.
I’m facing an issue with my Apache APISIX setup in a Docker container. I have configured a route in APISIX, but when I make a request, I get a 404 error. Here are the details of my setup:
Route Configuration:
{
"list": [
{
"createdIndex": 30,
"value": {
"host": "10.1.10.112",
"upstream": {
"pass_host": "pass",
"keepalive_pool": {
"idle_timeout": 60,
"size": 320,
"requests": 1000
},
"type": "roundrobin",
"timeout": {
"connect": 6,
"send": 6,
"read": 6
},
"scheme": "http",
"hash_on": "vars",
"nodes": {
"172.26.50.10:7011": 1
}
},
"name": "local-ords",
"priority": 100,
"status": 1,
"uri": "/api/cnam/test/18",
"update_time": 1738257518,
"create_time": 1738250330,
"id": "5497616673915544",
"methods": [
"GET",
"POST",
"PUT",
"DELETE",
"PATCH",
"HEAD",
"OPTIONS",
"CONNECT",
"TRACE",
"PURGE"
]
},
"modifiedIndex": 68,
"key": "/apisix/routes/5497616673915544"
}
],
"total": 1
}
The request URL is: http://<apisix_host>/api/cnam/test/18
The backend service at 172.26.50.10:7011
works fine when tested directly with cURL, i.e.: curl http://172.26.50.10:7011/api/cnam/test/18
.
However, when I send the request through APISIX, I always get a 404 error.
Double-checking the route configuration in APISIX and making sure it matches the expected path.
Ensuring that the upstream is correctly configured (I verified that 172.26.50.10:7011
is reachable from within the container).
Checking logs for any errors or warnings that might provide more information about the issue.
Apache APISIX Docker container Using a reverse proxy with APISIX to route requests to a backend service.
I'm pretty sure the problem is you are not passing the Host
header.
Your request should look like this:
curl http://172.26.50.10:7011/api/cnam/test/18 -H "Host: 10.1.10.112"
The host
attribute in a route is used to match incoming requests based on their Host header. This is typically done for virtual hosting and multi-tenant scenarios, and allows APISIX to route traffic based on different domain names (or IP addresses in your case).
If you configure your route to expect a specific host (or a list of hosts), APISIX will need the Host
header in order to know which service or website you are actually requesting. If you don't provide it, APISIX will respond with 404: Not Found
.
For reference: