topzyh opened a new issue, #7563:
URL: https://github.com/apache/apisix/issues/7563

   ### Current Behavior
   
   etcd data:
   ```
   {
       "scheme":"http",
       "name":"safebox-esp-web_web-console-cns2waf_5009",
       "desc":"Created by apisix-ingress-controller, DO NOT modify it manually",
       "id":"a48bc649",
       "update_time":1659003639,
       "create_time":1659003457,
       "nodes":[
           {
               "weight":100,
               "priority":0,
               "host":"2409:XXXX:XXXX:2000:0:1:afd:7d20",
               "port":4009
           },
           {
               "weight":100,
               "priority":0,
               "host":"2409:XXXX:XXXX:2000:0:1:afd:7d68",
               "port":4009
           }
       ],
       "type":"roundrobin",
       "labels":{
           "managed-by":"apisix-ingress-controller"
       },
       "hash_on":"vars",
       "pass_host":"pass"
   }
   ```
   
   I had modify **/usr/local/apisix/apisix/schema_def.lua  LINE 40**
   ```
   -- local host_def_pat = "^\\*?[0-9a-zA-Z-._]+$"
   local host_def_pat = "^\\*?[0-9a-zA-Z-._\\[\\]:]+$"
   ```
   
   AND   **/usr/local/apisix/apisix/balancer.lua LINE 294**
   ```
               local has_ipv6 = string.find(server.host, ":", 1, true)
               if (has_ipv6 ~= nil) then
                   local is_ipv6_plus = string.find(server.host, "[", 1, true)
                   if (is_ipv6_plus == nil) then
                       server.host = "["..server.host.."]"
                   end
               end
   
               local ok, err = balancer.set_current_peer(server.host, 
server.port, pool_opt)
   ```
   
   
   
   ### Expected Behavior
   
   _No response_
   
   ### Error Logs
   
   _No response_
   
   ### Steps to Reproduce
   
   I had modify **/usr/local/apisix/apisix/schema_def.lua  LINE 40**
   ```
   -- local host_def_pat = "^\\*?[0-9a-zA-Z-._]+$"
   local host_def_pat = "^\\*?[0-9a-zA-Z-._\\[\\]:]+$"
   ```
   
   AND   **/usr/local/apisix/apisix/balancer.lua LINE 294**
   ```
               local has_ipv6 = string.find(server.host, ":", 1, true)
               if (has_ipv6 ~= nil) then
                   local is_ipv6_plus = string.find(server.host, "[", 1, true)
                   if (is_ipv6_plus == nil) then
                       server.host = "["..server.host.."]"
                   end
               end
   
               local ok, err = balancer.set_current_peer(server.host, 
server.port, pool_opt)
   ```
   
   When upstream hosts count =1,its working;
   But upstream hosts  number >=2 ,error log:
   ```
   2022/07/28 10:07:09 [error] 51#51: *13796 [lua] balancer.lua:370: run(): 
failed to set server peer [[2409:XXXX:XXXX:2000:0:1:afd:7d65:4009]:nil] err: 
invalid IPv6 address while connecting to upstream, client: 10.253.91.92, 
server: _, request: "GET /web-console-cnswaf/ HTTP/1.1", host: "xxx.xxx.com"
   ```
   server.host = 2409:XXXX:XXXX:2000:0:1:afd:7d65:4009  (4009 is port)
   server.port = nil 
   
   ### Environment
   
   - APISIX version: 2.10.5uanme
   - Operating system: CentOS 7 , Linux 4.19
   - OpenResty version: 1.19.9.1
   - etcd version, if relevant: 3.4.0
   
   


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