You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2021/05/21 13:11:20 UTC

[GitHub] [apisix] coolbeevip opened a new issue #4290: 404 Route Not Found

coolbeevip opened a new issue #4290:
URL: https://github.com/apache/apisix/issues/4290


   Hi, I am a newbie APISIX.
   
   I just trying to create a route to an API the is up and running on my local machine.
   
   ### Issue description
   
   This is my upstream
   
   ```
   $ curl -i -X GET http://192.168.51.234:5005/nc-tools/actuator/health
   HTTP/1.1 200 OK
   Connection: keep-alive
   Transfer-Encoding: chunked
   Content-Type: application/vnd.spring-boot.actuator.v3+json
   Date: Fri, 21 May 2021 12:20:00 GMT
   
   {"status":"UP","components":{...}}
   ```
   
   I added UPSTREAM ​on the APISIX dashboard
   
   ```
   curl http://192.168.40.13:9080/apisix/admin/upstreams/355792372187005851 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1'
   
   {
   	"node": {
   		"key": "\/apisix\/upstreams\/355792372187005851",
   		"value": {
   			"nodes": [{
   				"weight": 100,
   				"host": "192.168.51.234",
   				"port": 5005
   			}],
   			"update_time": 1621598379,
   			"timeout": {
   				"read": 6,
   				"send": 6,
   				"connect": 6
   			},
   			"desc": "工具服务",
   			"name": "nc-tools",
   			"pass_host": "pass",
   			"retries": 3,
   			"type": "roundrobin",
   			"checks": {
   				"active": {
   					"unhealthy": {
   						"http_statuses": [429, 404, 500, 501, 502, 503, 504, 505],
   						"http_failures": 5,
   						"tcp_Failures": 2,
   						"timeouts": 3,
   						"interval": 1
   					},
   					"port": 5005,
   					"healthy": {
   						"interval": 1,
   						"successes": 2,
   						"http_statuses": [200, 302]
   					},
   					"timeout": 1,
   					"type": "http",
   					"host": "192.168.51.234",
   					"concurrency": 10,
   					"http_path": "\/actuator\/health"
   				}
   			},
   			"id": "355792372187005851",
   			"scheme": "http",
   			"create_time": 1621598379
   		}
   	},
   	"action": "get",
   	"count": "1"
   }
   ```
   
   And, I added ROUTE on the APISIX dashboard
   
   ```
   curl http://192.168.40.13:9080/apisix/admin/routes/355791849174074267 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1'
   
   {
   	"node": {
   		"key": "\/apisix\/routes\/355791849174074267",
   		"value": {
   			"name": "tools",
   			"id": "355791849174074267",
   			"status": 1,
   			"update_time": 1621598471,
   			"uris": ["\/tools"],
   			"upstream_id": "355792372187005851",
   			"labels": {
   				"API_VERSION": "1.0.0"
   			},
   			"desc": "tools",
   			"create_time": 1621598067
   		}
   	},
   	"action": "get",
   	"count": "1"
   }
   ```
   
   But, I got the **404 Route Not Found** when accessing my upstream service through APISIXI.
   
   ```
   $ curl -i -X GET http://192.168.40.13:9080/tools/nc-tools/actuator/health
   HTTP/1.1 404 Not Found
   Date: Fri, 21 May 2021 12:34:31 GMT
   Content-Type: text/plain; charset=utf-8
   Transfer-Encoding: chunked
   Connection: keep-alive
   Server: APISIX/2.5
   
   {"error_msg":"404 Route Not Found"}
   ```
   
   Is there something wrong with my configuration?
   
   ### Environment
   
   * apisix version (cmd: `apisix version`):
   
   ```
   $ ./bin/apisix version
   /usr/local/Cellar/openresty/1.19.3.1_1/luajit/bin/luajit ./apisix/cli/apisix.lua version
   2.5
   ```
   
   * OS (cmd: `uname -a`): 
   
   ```shell
   $ uname -a
   Darwin bogon 19.6.0 Darwin Kernel Version 19.6.0: Mon Aug 31 22:12:52 PDT 2020; root:xnu-6153.141.2~1/RELEASE_X86_64 x86_64
   ```
   
   * OpenResty / Nginx version (cmd: `nginx -V` or `openresty -V`):
   
   ```shell
   $ openresty -v
   nginx version: openresty/1.19.3.1
   ```
   
   * etcd version, if have (cmd: run `curl http://127.0.0.1:9090/v1/server_info` to get the info from server-info API):
   
   ```
   $ curl http://127.0.0.1:9090/v1/server_info
   {"version":"2.5","etcd_version":"3.4.0","up_time":352,"last_report_time":1621601752,"hostname":"bogon","id":"0ad4e9b1-f7f7-4960-86d7-e19ccff89ef5","boot_time":1621601452}
   ```
   
   * apisix-dashboard version, if have:
   
   ```shell
   $ ./manager-api
   The manager-api is running successfully!
   
   Version : 2.6
   GitHash : 9728a43
   Listen  : 0.0.0.0:9000
   ```
   * luarocks version, if the issue is about installation (cmd: `luarocks --version`):
   
   ```shell
   $ luarocks --version
   /usr/local/bin/luarocks 3.6.0
   LuaRocks main command-line interface
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] juzhiyuan commented on issue #4290: 404 Route Not Found

Posted by GitBox <gi...@apache.org>.
juzhiyuan commented on issue #4290:
URL: https://github.com/apache/apisix/issues/4290#issuecomment-846334249


   I see these two URLs are similar except the `center-x` is different, I would use `traffic-split` plugin to resolve this issue.
   
   Let's assume we have two URLs:
   
   1. `http://apisix:9080/nc-tools/actuator/health?center=center1`
   2. `http://apisix:9080/nc-tools/actuator/health?center=center2`
   
   And use `vars` to lead traffic to different upstreams. See https://apisix.apache.org/docs/apisix/plugins/traffic-split/#blue-green-release
   
   need @Firstsawyou to confirm.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] coolbeevip commented on issue #4290: 404 Route Not Found

Posted by GitBox <gi...@apache.org>.
coolbeevip commented on issue #4290:
URL: https://github.com/apache/apisix/issues/4290#issuecomment-846398513


   The traffic-split  `vars` supports passing through request header or URL parameters. 
   
   I noticed that **The var here is consistent with the naming of Nginx internal variables, so request_uri, host, etc.** in https://apisix.apache.org/docs/apisix/plugins/traffic-split/
   
   I still don't get it.  Can I do the following configuration similar to Nginx in APISIX?
   
   ```
   location /cloud/ {
       proxy_pass http://x.x.x.x:port/nc-tools/actuator/health
   }
   
   location /local/ {
       proxy_pass http://x.x.x.x:port/nc-tools/actuator/health
   }
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] Firstsawyou commented on issue #4290: 404 Route Not Found

Posted by GitBox <gi...@apache.org>.
Firstsawyou commented on issue #4290:
URL: https://github.com/apache/apisix/issues/4290#issuecomment-846706636


   > * I can't find it in the plugin configuration of the route create in APISIX Dashboard,  is this a global plugin?
   
   The proxy-rewrite plugin can be found on the first page of creating a route on the Dashboard:
   <img width="858" alt="截屏2021-05-24 上午11 19 05" src="https://user-images.githubusercontent.com/52862365/119292017-1d671f80-bc82-11eb-8a0d-20d188f20d75.png">
   
   
   >* I noticed than the configuration plugin API URI include ROUTD ID routes/1 in https://apisix.apache.org/docs/apisix/plugins/proxy-rewrite/#how-to-enable
   
   >Does this mean that a plugin can be configured when creating a route
   >Or, Is this a defect of the dashboard? Is it still only possible to configure the proxy-rewrite plugin through the API?
   
   There are two ways to configure APISIX routing data:
   1. Configure via Admin API, which is this way: https://apisix.apache.org/docs/apisix/plugins/proxy-rewrite/#how-to-enable
   
   2. Configure via APISIX Dashboard page;
   
   Therefore, proxy-rewrite plugin configuration can be done through Dashboard.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] coolbeevip commented on issue #4290: 404 Route Not Found

Posted by GitBox <gi...@apache.org>.
coolbeevip commented on issue #4290:
URL: https://github.com/apache/apisix/issues/4290#issuecomment-846708974


   Thank you, I will just try it later.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] coolbeevip commented on issue #4290: 404 Route Not Found

Posted by GitBox <gi...@apache.org>.
coolbeevip commented on issue #4290:
URL: https://github.com/apache/apisix/issues/4290#issuecomment-846497578


   Thanks so much again
   
   > > I still don't get it. Can I do the following configuration similar to Nginx in APISIX?
   > > ```
   > > location /cloud/ {
   > >     proxy_pass http://x.x.x.x:port/nc-tools/actuator/health
   > > }
   > > 
   > > location /local/ {
   > >     proxy_pass http://x.x.x.x:port/nc-tools/actuator/health
   > > }
   > > ```
   > 
   > You can create two routes and use the proxy-rewrite plugin to implement them. Please refer here: https://apisix.apache.org/zh/docs/apisix/plugins/proxy-rewrite
   > 
   > Example:
   > 
   > ```shell
   > # route 1
   > curl http://127.0.0.1:9080/apisix/admin/routes  -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X POST -d '
   > {
   >     "uri": "/cloud",
   >     "plugins": {       
   >         "proxy-rewrite": {
   >             "uri": "/nc-tools/actuator/health"
   >         }
   >     },
   >     "upstream": {
   >         "type": "roundrobin",
   >         "nodes": {
   >             "x.x.x.x:port": 1
   >         }
   >     }
   > }'
   > 
   > # route 2
   > curl http://127.0.0.1:9080/apisix/admin/routes  -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X POST -d '
   > {
   >     "uri": "/local",
   >     "plugins": {       
   >         "proxy-rewrite": {
   >             "uri": "/nc-tools/actuator/health"
   >         }
   >     },
   >     "upstream": {
   >         "type": "roundrobin",
   >         "nodes": {
   >             "x.x.x.x:port": 1
   >         }
   >     }
   > }'
   > ```
   
   Thanks so much again


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] Firstsawyou commented on issue #4290: 404 Route Not Found

Posted by GitBox <gi...@apache.org>.
Firstsawyou commented on issue #4290:
URL: https://github.com/apache/apisix/issues/4290#issuecomment-846048778


   > "uris": ["\/tools"],
   
   The uri here should be configured like this: `"uris": ["/nc-tools/actuator/health"]`
   It should be consistent with the uri guarantee provided by your backend service.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] coolbeevip edited a comment on issue #4290: 404 Route Not Found

Posted by GitBox <gi...@apache.org>.
coolbeevip edited a comment on issue #4290:
URL: https://github.com/apache/apisix/issues/4290#issuecomment-846331723


   > > "uris": ["/tools"],
   > 
   > The uri here should be configured like this: `"uris": ["/nc-tools/actuator/health"]`
   > It should be consistent with the uri guarantee provided by your backend service.
   
   Thank you for your feedback. It's worked after change route path  `"uris": ["/nc-tools/actuator/health"]` .
   
   My original scenario is as follows:
   
   I have two upstream API
   
   * upstream-1 http://x.x.x.x:port/nc-tools/actuator/health
   * upstream-2 http://x.x.x.x:port/nc-tools/actuator/health
   
   I want to configure two routes with different paths to access them.
   
   * route-1 path /center1/*
   * route-2 path /center2/*
   
   I expected routes are followed: Right?Or should I use **Advanced Routing Matching Conditions** ? 
   
   ```
   http://apisix:9098/center1/nc-tools/actuator/health --> route-1 --> upstream-1
   http://apisix:9098/center2/nc-tools/actuator/health --> route-2 --> upstream-2
   ```
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] coolbeevip commented on issue #4290: 404 Route Not Found

Posted by GitBox <gi...@apache.org>.
coolbeevip commented on issue #4290:
URL: https://github.com/apache/apisix/issues/4290#issuecomment-846331723


   > > "uris": ["/tools"],
   > 
   > The uri here should be configured like this: `"uris": ["/nc-tools/actuator/health"]`
   > It should be consistent with the uri guarantee provided by your backend service.
   
   Thank you for your feedback. It's worked after change route path  `"uris": ["/nc-tools/actuator/health"]` .
   
   My original scenario is as follows:
   
   I have two upstream API
   
   * upstream-1 http://x.x.x.x:port/nc-tools/actuator/health
   * upstream-2 http://x.x.x.x:port/nc-tools/actuator/health
   
   I want to configure two routes with different paths to access them.
   
   * route-1 path /center1/*
   * route-2 path /center2/*
   
   I expected routes are followed: Right?
   
   http://apisix:9098/center1/nc-tools/actuator/health --> route-1 --> upstream-1
   http://apisix:9098/center2/nc-tools/actuator/health --> route-2 --> upstream-2
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] coolbeevip commented on issue #4290: 404 Route Not Found

Posted by GitBox <gi...@apache.org>.
coolbeevip commented on issue #4290:
URL: https://github.com/apache/apisix/issues/4290#issuecomment-846335021


   > center-x
   
   route path `/center-x ` is customized URL by me, it is not part of the upstream service API


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] coolbeevip commented on issue #4290: 404 Route Not Found

Posted by GitBox <gi...@apache.org>.
coolbeevip commented on issue #4290:
URL: https://github.com/apache/apisix/issues/4290#issuecomment-846679549


   Hi, @Firstsawyou 
   
   I am here again. I have some queries for plugin proxy-rewrite.
   
   * I can't find it in the plugin configuration of the route create in APISIX Dashboard,  is this a global plugin? 
     
     As here says  https://github.com/apache/apisix-dashboard/issues/1719#issuecomment-816028775)
   
   * I noticed than the configuration plugin API  URI  include ROUTD ID `routes/1` in https://apisix.apache.org/docs/apisix/plugins/proxy-rewrite/#how-to-enable
      
     Does this mean that a plugin can be configured when creating a route
   
   Or, Is this a defect of the dashboard? Is it still only possible to configure the proxy-rewrite plugin through the API?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] coolbeevip closed issue #4290: 404 Route Not Found

Posted by GitBox <gi...@apache.org>.
coolbeevip closed issue #4290:
URL: https://github.com/apache/apisix/issues/4290


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] juzhiyuan commented on issue #4290: 404 Route Not Found

Posted by GitBox <gi...@apache.org>.
juzhiyuan commented on issue #4290:
URL: https://github.com/apache/apisix/issues/4290#issuecomment-846336191


   Yes, I mean if using `traffic-split` with `vars`, you could use `arg_xxx` to split traffic.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] Firstsawyou commented on issue #4290: 404 Route Not Found

Posted by GitBox <gi...@apache.org>.
Firstsawyou commented on issue #4290:
URL: https://github.com/apache/apisix/issues/4290#issuecomment-846439066


   > I still don't get it. Can I do the following configuration similar to Nginx in APISIX?
   > 
   > ```
   > location /cloud/ {
   >     proxy_pass http://x.x.x.x:port/nc-tools/actuator/health
   > }
   > 
   > location /local/ {
   >     proxy_pass http://x.x.x.x:port/nc-tools/actuator/health
   > }
   > ```
   
   You can create two routes and use the proxy-rewrite plugin to implement them. Please refer here: https://apisix.apache.org/zh/docs/apisix/plugins/proxy-rewrite
   
   Example:
   
   ```shell
   # route 1
   curl http://127.0.0.1:9080/apisix/admin/routes  -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X POST -d '
   {
       "uri": "/cloud",
       "plugins": {       
           "proxy-rewrite": {
               "uri": "/nc-tools/actuator/health"
           }
       },
       "upstream": {
           "type": "roundrobin",
           "nodes": {
               "x.x.x.x:port": 1
           }
       }
   }'
   
   # route 2
   curl http://127.0.0.1:9080/apisix/admin/routes  -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X POST -d '
   {
       "uri": "/local",
       "plugins": {       
           "proxy-rewrite": {
               "uri": "/nc-tools/actuator/health"
           }
       },
       "upstream": {
           "type": "roundrobin",
           "nodes": {
               "x.x.x.x:port": 1
           }
       }
   }'
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] Firstsawyou commented on issue #4290: 404 Route Not Found

Posted by GitBox <gi...@apache.org>.
Firstsawyou commented on issue #4290:
URL: https://github.com/apache/apisix/issues/4290#issuecomment-846390046


   > I see these two URLs are similar except the `center-x` is different, I would use `traffic-split` plugin to resolve this issue.
   > 
   > Let's assume we have two URLs:
   > 
   > 1. `http://apisix:9080/nc-tools/actuator/health?center=center1`
   > 2. `http://apisix:9080/nc-tools/actuator/health?center=center2`
   > 
   > And use `vars` to lead traffic to different upstreams. See https://apisix.apache.org/docs/apisix/plugins/traffic-split/#blue-green-release
   > 
   > need @Firstsawyou to confirm.
   
   This is a good method.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] coolbeevip commented on issue #4290: 404 Route Not Found

Posted by GitBox <gi...@apache.org>.
coolbeevip commented on issue #4290:
URL: https://github.com/apache/apisix/issues/4290#issuecomment-846385416


   > see https://apisix.apache.org/docs/apisix/plugins/traffic-split/#blue-green-release
   
   Thanks for your information and for being so helpful, It's worked. 🙏 I wrote a [blog](https://coolbeevip.github.io/posts/study-notes-for-apisix-2-plugins-traffic-split/) for this, hoping to help newbies like me
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] coolbeevip commented on issue #4290: 404 Route Not Found

Posted by GitBox <gi...@apache.org>.
coolbeevip commented on issue #4290:
URL: https://github.com/apache/apisix/issues/4290#issuecomment-846336346


   > Yes, I mean if using `traffic-split` with `vars`, you could use `arg_xxx` to split traffic.
   
   Thank you, I'll take a look at `traffic-split`


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] spacewander closed issue #4290: 404 Route Not Found

Posted by GitBox <gi...@apache.org>.
spacewander closed issue #4290:
URL: https://github.com/apache/apisix/issues/4290


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] juzhiyuan commented on issue #4290: 404 Route Not Found

Posted by GitBox <gi...@apache.org>.
juzhiyuan commented on issue #4290:
URL: https://github.com/apache/apisix/issues/4290#issuecomment-846337142


   see https://apisix.apache.org/docs/apisix/plugins/traffic-split/#blue-green-release


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org