nfrankel opened a new issue #6330:
URL: https://github.com/apache/apisix/issues/6330


   ### Issue description
   
   The `proxy-mirror` plugin validates the `host` pattern with the following 
regex: `[[^http(s)?:\/\/[a-zA-Z0-9][-a-zA-Z0-9]{0,62}]] .. 
[[(\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+(:[0-9]{1,5})?$]]`.
   
   In specific scenarios, the pattern is too restrictive. For example, in 
Docker Compose, the host is a single name with no dot, _e.g._, `backend`.
   
   ### Environment
   
   - apisix version (cmd: `apisix version`): `2.12.0`
   - OS (cmd: `uname -a`): `Linux 53df324263a6 5.10.76-linuxkit #1 SMP PREEMPT 
Mon Nov 8 11:22:26 UTC 2021 aarch64 Linux`
   - OpenResty / Nginx version (cmd: `nginx -V` or `openresty -V`): `nginx 
version: openresty/1.19.9.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): 
`404 page not found`
   - apisix-dashboard version, if have: - 
   - the plugin runner version, if the issue is about a plugin runner (cmd: 
depended on the kind of runner): -
   - luarocks version, if the issue is about installation (cmd: `luarocks 
--version`): -
   
   
   ### Steps to reproduce
   
   1. Start APISIX
   2. Enable the `proxy-mirror` plugin
   3. Create a route:
   
       curl -v -i http://apisix:9080/apisix/admin/routes/1 -H 'X-API-KEY: 
edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
         {
           "methods": ["GET"],
           "uris": ["/hello"],
           "upstream": {
             "type": "roundrobin",
             "nodes": {
               "oldapi:8081": 1
             }
           }
           "plugins": {
             "proxy-mirror": {
               "host": "http://newapi:8082";
             }
           }
         }'
   
   4. Use the route:
   
       `curl localhost:9080/hello'
   
   ### Actual result
   
   ```
   {"error_msg":"failed to check the configuration of plugin proxy-mirror err: 
property \"host\" validation failed: failed to match pattern 
\"^http(s)?:\\\\\/\\\\\/[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\\\\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+(:[0-9]{1,5})?$\"
 with \"http:\/\/newapi:8082\""}
   ```
   
   ### Error log
   
   There's no error log
   
   ### Expected result
   
   Plugin is configured and traffic is mirrored


-- 
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