apisix icon indicating copy to clipboard operation
apisix copied to clipboard

404 Route Not Found in apisix 3.6.1

Open githubxubin opened this issue 1 year ago • 18 comments

Description

I upgraded apsix from 3.2 to 3.6, but there was a confusing problem, I deployed APSIX-3.6.0 on the centos server normally, but the Route is Not available, it is always "error_msg": "404 Route Not Found", Here are my configuration and steps

config.yaml:

apisix:
  node_listen: 9080              # APISIX listening port
  enable_ipv6: false
  enable_control: true
  control:
    ip: "0.0.0.0"
    port: 9092

deployment:
  role: traditional            # Set deployment mode: traditional, control_plane, or data_plane.
  role_traditional:
    config_provider: etcd      # Set the configuration center.
  admin:
    allow_admin:               # http://nginx.org/en/docs/http/ngx_http_access_module.html#allow
      - 0.0.0.0/0              # We need to restrict ip access rules for security. 0.0.0.0/0 is for test.

    admin_key:
      - name: "admin"
        key: edd1c9f034335f136f87ad84b625c8f1
        role: admin                 # admin: manage all configuration data

      - name: "viewer"
        key: 4054f7cf07e344346cd3f287985e76a2
        role: viewer
  etcd:
    host:                           # it's possible to define multiple etcd hosts addresses of the same etcd cluster.
      - "http://etcd:2379"          # multiple etcd address
    prefix: "/apisix"               # apisix configurations prefix
    timeout: 30                     # 30 seconds

my step: 1.set route:

{
    "id": "499092110205518536",
    "create_time": 1707011679,
    "update_time": 1707024699,
    "uri": "/test/*",
    "name": "test",
    "groupId": "1",
    "openId": "",
    "priority": 1,
    "methods": [
        "GET",
        "POST",
        "PUT",
        "DELETE",
        "PATCH",
        "HEAD",
        "OPTIONS"
    ],
    "upstream": {
        "nodes": [
            {
                "host": "10.210.21.105",
                "port": 1001,
                "weight": 1
            }
        ],
        "retries": 0,
        "timeout": {
            "connect": 6,
            "send": 6,
            "read": 6
        },
        "type": "roundrobin",
        "scheme": "http",
        "discovery_args": {
            "group_name": "",
            "namespace_id": ""
        },
        "pass_host": "pass",
        "keepalive_pool": {
            "idle_timeout": 60,
            "requests": 1000,
            "size": 320
        }
    },
    "status": 1
}
  1. request route: [root@mysql5 apisix_log]# curl http://10.210.21.130:9080/test/ {"error_msg":"404 Route Not Found"} 3.get the error result:
192.168.97.25 - - [04/Feb/2024:05:45:13 +0000] 10.210.21.130:9080 "GET /test/ HTTP/1.1" 404 47 0.000 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36" - - - "http://10.210.21.130:9080"

I don't know if the version has a bug(Local testing is normal (macos11.3))

Environment

  • APISIX version (run apisix version):3.6.0-centos
  • Operating system (run uname -a):
  • OpenResty / Nginx version (run openresty -V or nginx -V):
  • etcd version, if relevant (run curl http://127.0.0.1:9090/v1/server_info):
  • APISIX Dashboard version, if relevant: 3.0
  • Plugin runner version, for issues related to plugin runners:
  • LuaRocks version, for installation issues (run luarocks --version):

githubxubin avatar Feb 04 '24 05:02 githubxubin

@indrekj @huacnlee @markokocic @jaysonsantos

githubxubin avatar Feb 04 '24 06:02 githubxubin

Can you show me the result of the command

curl` "http://127.0.0.1:9180/apisix/admin/routes?page=1&page_size=10" -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X GET

theweakgod avatar Feb 05 '24 00:02 theweakgod

2. curl http://10.210.21.130:9080/test/

[root@mysql5]# curl "http://127.0.0.1:9180/apisix/admin/routes?page=1&page_size=10" -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X GET
{"list":[{"key":"/apisix/routes/499247217815585478","modifiedIndex":132,"value":{"uri":"/test/*","methods":["GET","POST","PUT","DELETE","PATCH","HEAD","OPTIONS"],"status":1,"update_time":1707104130,"priority":1,"groupId":"1","openId":"","upstream":{"timeout":{"send":6,"connect":6,"read":6},"keepalive_pool":{"requests":1000,"size":320,"idle_timeout":60},"retries":0,"nodes":[{"port":1001,"weight":1,"host":"10.210.21.105"}],"pass_host":"pass","scheme":"http","discovery_args":{"group_name":"","namespace_id":""},"type":"roundrobin"},"create_time":1707104130,"id":"499247217815585478","name":"test"},"createdIndex":132}],"total":1}

[root@mysql5]# curl http://127.0.0.1:9080/test/
{"error_msg":"404 Route Not Found"}

githubxubin avatar Feb 05 '24 03:02 githubxubin

Can you show me the result of the command

curl` "http://127.0.0.1:9180/apisix/admin/routes?page=1&page_size=10" -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X GET

Please take a look. It's very urgent. Thank you

githubxubin avatar Feb 05 '24 05:02 githubxubin

Can you set up routing in this format? I have not reproduced your problem, please follow this format to set router.

{
  "uri": "/status/*",
  "name": "test1",
  "methods": [
    "GET",
    "POST",
    "PUT"
  ],
  "upstream": {
    "nodes": [
      {
        "host": "localhost",
        "port": 2112,
        "weight": 1
      }
    ],
    "timeout": {
      "connect": 6,
      "send": 6,
      "read": 6
    },
    "type": "roundrobin",
    "scheme": "http",
    "pass_host": "pass",
    "keepalive_pool": {
      "idle_timeout": 60,
      "requests": 1000,
      "size": 320
    }
  },
  "status": 1
}

theweakgod avatar Feb 05 '24 05:02 theweakgod

```shell
curl` "http://127.0.0.1:9180/apisix/admin/routes?page=1&page_size=10" -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X GET

The same effect, or 404, my local development is also normal, is there a problem with what configuration, this is too strange

image

[root@localhost apisix-dashboard]# curl http://10.210.21.130:9080/status/ -v
* About to connect() to 10.210.21.130 port 9080 (#0)
*   Trying 10.210.21.130...
* Connected to 10.210.21.130 (10.210.21.130) port 9080 (#0)
> GET /status/ HTTP/1.1
> User-Agent: curl/7.29.0
> Host: 10.210.21.130:9080
> Accept: */*
> 
< HTTP/1.1 404 Not Found
< Date: Mon, 05 Feb 2024 06:00:39 GMT
< Content-Type: text/plain; charset=utf-8
< Transfer-Encoding: chunked
< Connection: keep-alive
< Server: APISIX/3.6.0
< 
{"error_msg":"404 Route Not Found"}
* Connection #0 to host 10.210.21.130 left intact
[root@localhost apisix-dashboard]# 

[root@mysql5]# curl "http://127.0.0.1:9180/apisix/admin/routes?page=1&page_size=10" -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X GET
{"total":2,"list":[{"value":{"name":"test","groupId":"1","openId":"","upstream":{"retries":0,"timeout":{"send":6,"connect":6,"read":6},"discovery_args":{"group_name":"","namespace_id":""},"type":"roundrobin","pass_host":"pass","keepalive_pool":{"idle_timeout":60,"requests":1000,"size":320},"nodes":[{"port":1001,"host":"10.210.21.105","weight":1}],"scheme":"http"},"create_time":1707104130,"id":"499247217815585478","uri":"/test/*","priority":1,"update_time":1707112682,"methods":["GET","POST","PUT","DELETE","PATCH","HEAD","OPTIONS"],"status":0},"createdIndex":132,"key":"/apisix/routes/499247217815585478","modifiedIndex":266},{"value":{"name":"test1","groupId":"","openId":"","upstream":{"scheme":"http","type":"roundrobin","pass_host":"pass","keepalive_pool":{"idle_timeout":60,"requests":1000,"size":320},"nodes":[{"port":2112,"host":"localhost","weight":1}],"timeout":{"send":6,"connect":6,"read":6}},"create_time":1707112686,"id":"499261571847946959","uri":"/status/*","update_time":1707112821,"methods":["GET","POST","PUT"],"status":1},"createdIndex":267,"key":"/apisix/routes/499261571847946959","modifiedIndex":268}]}

githubxubin avatar Feb 05 '24 06:02 githubxubin

Can you set up routing in this format? I have not reproduced your problem, please follow this format to set router.

{
  "uri": "/status/*",
  "name": "test1",
  "methods": [
    "GET",
    "POST",
    "PUT"
  ],
  "upstream": {
    "nodes": [
      {
        "host": "localhost",
        "port": 2112,
        "weight": 1
      }
    ],
    "timeout": {
      "connect": 6,
      "send": 6,
      "read": 6
    },
    "type": "roundrobin",
    "scheme": "http",
    "pass_host": "pass",
    "keepalive_pool": {
      "idle_timeout": 60,
      "requests": 1000,
      "size": 320
    }
  },
  "status": 1
}

I also tried the 3.7 mirror and it was the same problem

githubxubin avatar Feb 05 '24 06:02 githubxubin

Can you set up routing in this format? I have not reproduced your problem, please follow this format to set router.

{
  "uri": "/status/*",
  "name": "test1",
  "methods": [
    "GET",
    "POST",
    "PUT"
  ],
  "upstream": {
    "nodes": [
      {
        "host": "localhost",
        "port": 2112,
        "weight": 1
      }
    ],
    "timeout": {
      "connect": 6,
      "send": 6,
      "read": 6
    },
    "type": "roundrobin",
    "scheme": "http",
    "pass_host": "pass",
    "keepalive_pool": {
      "idle_timeout": 60,
      "requests": 1000,
      "size": 320
    }
  },
  "status": 1
}

Can you take a look

githubxubin avatar Feb 05 '24 07:02 githubxubin

Did you check out the error log?

theweakgod avatar Feb 05 '24 08:02 theweakgod

Did you check out the error log?

No match. The log level is info

2024/02/05 08:46:51 [info] 50#50: *6315 [lua] radixtree_host_uri.lua:161: match(): route match mode: radixtree_host_uri, client: 192.168.96.194, server: _, request: "GET /status/ HTTP/1.1", host: "10.20.60.51"
2024/02/05 08:46:51 [info] 50#50: *6315 [lua] init.lua:633: http_access_phase(): not find any matched route, client: 192.168.96.194, server: _, request: "GET /status/ HTTP/1.1", host: "10.20.60.51"
2024/02/05 08:46:51 [info] 50#50: *6315 client 192.168.96.194 closed keepalive connection

githubxubin avatar Feb 05 '24 08:02 githubxubin

Did you check out the error log?

the access log:

192.168.96.194 - - [05/Feb/2024:08:46:51 +0000] 10.20.60.51 "GET /status/ HTTP/1.1" 404 47 0.000 "-" "PostmanRuntime-ApipostRuntime/1.1.0" - - - "http://10.20.60.51"

githubxubin avatar Feb 05 '24 08:02 githubxubin

Can someone help with this @theweakgod @indrekj @huacnlee @markokocic

githubxubin avatar Feb 05 '24 09:02 githubxubin

You didn't set the host, but you used the host uri mode. This is strange. Can you set the host?

theweakgod avatar Feb 05 '24 13:02 theweakgod

Hi @githubxubin Is the problem only with this route? Are the others working stably?

  1. if you try to replace from "uri": "/test/*" to "uri": "/test", and send the reqest without the last backslash (like http://10.210.21.130:9080/test ), will it work?

  2. Are you sure that your upstream 10.210.21.105.1001 is working correctly? try sending the request directly, ignoring apisix, or from apisix container.

forcanza avatar Feb 05 '24 16:02 forcanza

Hi @githubxubin Is the problem only with this route? Are the others working stably?

  1. if you try to replace from "uri": "/test/*" to "uri": "/test", and send the reqest without the last backslash (like http://10.210.21.130:9080/test ), will it work?
  2. Are you sure that your upstream 10.210.21.105.1001 is working correctly? try sending the request directly, ignoring apisix, or from apisix container.
  1. I still got 404 according to what you said. 2.10.210.21.105.1001 / test is normal service, in addition, the Route 404 Not Found is apisix returned, Not to the upstream, and this should be no relationship, I'm on the 3.2 - centos is normal, upgrade to 3.6 this kind of problem

route config:

{
  "uri": "/test",
  "name": "test",
  "groupId": "",
  "openId": "",
  "priority": 1,
  "methods": [
    "GET",
    "POST",
    "PUT",
    "DELETE",
    "PATCH",
    "HEAD",
    "OPTIONS"
  ],
  "upstream": {
    "nodes": [
      {
        "host": "10.210.21.105",
        "port": 1001,
        "weight": 1
      }
    ],
    "retries": 0,
    "timeout": {
      "connect": 6,
      "send": 6,
      "read": 6
    },
    "type": "roundrobin",
    "scheme": "http",
    "pass_host": "pass",
    "keepalive_pool": {
      "idle_timeout": 60,
      "requests": 1000,
      "size": 320
    }
  },
  "status": 1
}

githubxubin avatar Feb 06 '24 01:02 githubxubin

I'm not sure why you're using the radixtree_host_uri as router match mode, as you've only set the URI without setting the host. I believe you need to set your router's host and include the host when sending requests. Let's try that and see if the requests go through. The requests have reached APISIX, but the router didn't match, resulting in a 404 error.

theweakgod avatar Feb 06 '24 07:02 theweakgod

Have u resolved this issue?

theweakgod avatar Feb 07 '24 02:02 theweakgod

Have u resolved this issue?

theweakgod avatar Feb 18 '24 09:02 theweakgod

Due to lack of the reporter's response this issue has been labeled with "no response". It will be close in 3 days if no further activity occurs. If this issue is still relevant, please simply write any comment. Even if closed, you can still revive the issue at any time or discuss it on the [email protected] list. Thank you for your contributions.

github-actions[bot] avatar May 21 '24 10:05 github-actions[bot]

This issue has been closed due to lack of activity. If you think that is incorrect, or the issue requires additional review, you can revive the issue at any time.

github-actions[bot] avatar May 24 '24 10:05 github-actions[bot]