Getting 404 Error in Apache APISIX Docker container despite correct route configuration - Stack Overflow

admin2025-04-18  3

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.

What I've tried

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.

Environment

Apache APISIX Docker container Using a reverse proxy with APISIX to route requests to a backend service.

What might be happening

  • Is there any misconfiguration in the route definition or in the communication between APISIX and the backend service?
  • Could the issue be related to Docker networking or proxy configuration, as the backend service works fine outside APISIX?
  • Why am I getting a 404 error despite the route being configured correctly and the backend service working as expected?

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.

What I've tried

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.

Environment

Apache APISIX Docker container Using a reverse proxy with APISIX to route requests to a backend service.

What might be happening

  • Is there any misconfiguration in the route definition or in the communication between APISIX and the backend service?
  • Could the issue be related to Docker networking or proxy configuration, as the backend service works fine outside APISIX?
  • Why am I getting a 404 error despite the route being configured correctly and the backend service working as expected?
Share Improve this question edited Jan 30 at 16:49 mikyll98 2,3133 gold badges15 silver badges43 bronze badges asked Jan 30 at 16:13 user3090303user3090303 719 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

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:

  • APISIX Docs | Admin API: Route body params
  • IBM Docs | Virtual Hosts
转载请注明原文地址:http://anycun.com/QandA/1744906912a89304.html