tzssangglass commented on issue #6171:
URL: https://github.com/apache/apisix/issues/6171#issuecomment-1018143725


   you can use `radixtree_host_uri` as route match. see: 
https://github.com/apache/apisix/blob/5513f1f66bdd047120936a6b1cc7340741c94366/docs/en/latest/architecture-design/router.md
   
   the `config.yaml` as
   
   ```yaml
   apisix:
     admin_key:
       - name: admin
         key: edd1c9f034335f136f87ad84b625c8f1  # using fixed API token has 
security risk, please update it when you deploy to production environment
         role: admin
     router:
       http: radixtree_host_uri
   ```
   
   route1
   ```
   curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: 
edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
   {
   "upstream": {
   "nodes": {
   "192.168.0.3:8081": 1
   },
   "type": "roundrobin"
   },
   "hosts": ["*.test1.com"],
   "uris": [ "/v1/*"],
   "priority": 10
   }'
   ```
   
   route2
   ```
   curl http://127.0.0.1:9080/apisix/admin/routes/2 -H 'X-API-KEY: 
edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
   {
   "upstream": {
   "nodes": {
   "192.168.0.3:8082": 1
   },
   "type": "roundrobin"
   },
   "hosts": ["a.test1.com"],
   "uris": [ "/v1/*"],
   "priority": 1
   }'
   ```
   
   and test
   ```
   curl --resolve "a.test1.com:9080:127.0.0.1" -I http://a.test1.com:9080/v1/a
   ```
   
   the log
   ```
   127.0.0.1 - - [21/Jan/2022:11:49:09 +0800] a.test1.com:9080 "HEAD /v1/a 
HTTP/1.1" 502 0 15.005 "-" "curl/7.64.1" 192.168.0.3:8082 502 15.005 
"http://a.test1.com:9080";
   ```
   
   - the `uris` is same
   - route2's priority less then route1's
   - route2's hosts is is well defined, not regex
   
   Is this what you want?


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to