apisix icon indicating copy to clipboard operation
apisix copied to clipboard

docs: getting-started-ip example doesn't work the api consumer request returns 404

Open phpdave opened this issue 2 years ago • 10 comments

Current State

The documentation on this page: https://apisix.apache.org/docs/apisix/getting-started/configure-routes/

states to use

curl -i "http://127.0.0.1:9180/apisix/admin/routes" -X PUT -d '
{
  "id": "getting-started-ip",
  "uri": "/ip",
  "upstream": {
    "type": "roundrobin",
    "nodes": {
      "httpbin.org:80": 1
    }
  }
}'

when i use that and then run

 curl "http://127.0.0.1:9080/ip"

I get

<html><head><title>Not Found</title></head><body><h1>404 Not Found</h1></body></html>

Desired State

I think the admin request should use 443 because that works

curl -i "http://127.0.0.1:9180/apisix/admin/routes" -X PUT -d '
{
  "id": "getting-started-ip",
  "uri": "/ip",
  "upstream" : {
    "type": "roundrobin",
    "nodes": {
      "httpbin.org:443": 1
    },
    "pass_host": "node",
    "scheme": "https"
  }
}'

phpdave avatar Apr 26 '24 02:04 phpdave

I have try http://httpbin.org/ is working . https://httpbin.org is working too. image

hanqingwu avatar Apr 28 '24 01:04 hanqingwu

I cannot reproduce either. The HTTP port with httpbin.org should work. When you create the route, did it create successfully with a 201 response code?

Sometimes the etcd nodes take a couple seconds to be ready and if you happen to be creating routes during then, the route is not created.

kayx23 avatar Apr 28 '24 02:04 kayx23

I have try http://httpbin.org/ is working . https://httpbin.org is working too. image

Yes direct connections to http://httpbin.org/ work but connections through APISIX with a route to httpbin.org:80 doesnt work http://127.0.0.1:9080/ip.

I cannot reproduce either. The HTTP port with httpbin.org should work. When you create the route, did it create successfully with a 201 response code?

Sometimes the etcd nodes take a couple seconds to be ready and if you happen to be creating routes during then, the route is not created.

I just recreated the situation using the documentation

curl -sL https://run.api7.ai/apisix/quickstart | sh
curl -i "http://127.0.0.1:9180/apisix/admin/routes" -X PUT -d '
{
  "id": "getting-started-ip",
  "uri": "/ip",
  "upstream": {
    "type": "roundrobin",
    "nodes": {
      "httpbin.org:80": 1
    }
  }
}'
curl "http://127.0.0.1:9080/ip"

image

phpdave avatar Apr 28 '24 15:04 phpdave

image

Cannot reproduce. Very strange case. Any more context?

kayx23 avatar Apr 29 '24 01:04 kayx23

From your screenshot, it seems that you have gotten a 404 not found HTML page when visiting the route:

image

Not sure how this happened and this doesn't look like it's from APISIX... Because if you request a route that does not exist, the message you get should look like this:

image

kayx23 avatar Apr 29 '24 01:04 kayx23

Maybe some oddity of WSL2

All happens within .000075 seconds

image

phpdave avatar Apr 29 '24 04:04 phpdave

will try it again on a Mac to see if its WSL related

phpdave avatar Apr 29 '24 04:04 phpdave

Ok I can confirm this is an oddity of running it on Windows WSL2. This works fine on a Mac. Perhaps the documentation should mention WSL2 having oddities?

phpdave avatar Apr 29 '24 17:04 phpdave

Perhaps the documentation should mention WSL2 having oddities?

I think it should be more specific than "oddities" if this goes on doc and should be understood better. I don't have windows system and cannot investigate further. If you have any ideas, feel free to open a PR. Thanks.

kayx23 avatar Apr 30 '24 02:04 kayx23

Perhaps the documentation should mention WSL2 having oddities?

Need someone with WSL2 environment to check and determine the next actionable item for this issue.

kayx23 avatar May 11 '24 06:05 kayx23

Closing this issue now as the original reporter's issue has been resolved.

As for the WSL2 oddity (not consistently reported) it can be opened as a new issue if anyone runs into it in the future.

kayx23 avatar Aug 02 '24 05:08 kayx23