-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug: APISIX 2.10.5 (LTS) can't support IPv6 Upstream host IP #7563
Comments
@kingluo |
@topzyh Why the address in your test output doesn't match the configuration in etcd? You should not quote the host with brackets to invoke Instead, I think the ingress controller should quote the |
@kingluo Is it possible to support IPv6 without bracket? Support this format will be great so people don't need to deal with the Nginx's special behavior. |
No, it's not nginx specific. In convention, to concatent with the port, the ipv6 must be quoted with bracket. So nginx does the right thing. In fact, here the issue is not triggered by nginx only. When apisix constructs the balancer, it would merge the address and port of each upstream as server url. After the server picker picks a server, it would parse the server url back into host and port. But since the address part of the server url is not quoted with brackets, it would fail to parse the ipv6 address, then leave the host value as the same server url value (2409:XXXX:XXXX:2000:0:1:afd:7d65:4009), and port is nil! Check https://github.com/apache/apisix/blob/master/apisix/balancer.lua#L193 and https://github.com/apache/apisix/blob/master/apisix/core/utils.lua#L156 for codes. In the output by @topzyh, he modifies the codes to quote the host with brackets in the wrong place, then it comes in another story: nginx try to parse it as ipv6 address, and find it's in wrong format (with extra port in tail). And in fact, in our ipv6 test, the input host is quoted with brackets, so it passes. So all in all, in my opinion, the solution is, either we adjust the admin API to quote the ipv6 address automatically, or we require the user to quote the ipv6 address with brackets. It's a bug in our codes. |
Thanks @kingluo @spacewander
再次感谢您的解答。 |
Yes, the bug is fixed. There are two formats of For the hash table case, if the node is ipv6 with port, then the ipv6 address must be quoted with square brackets, otherwise it's impossible to distingush the port from node. For node array, since the address and port are specified seperately, the bugfix would quote the address if the address is ipv6 automatically. |
Current Behavior
etcd data:
Expected Behavior
No response
Error Logs
No response
Steps to Reproduce
I had modify /usr/local/apisix/apisix/schema_def.lua LINE 40
AND /usr/local/apisix/apisix/balancer.lua LINE 294
When upstream hosts count =1,its working;
But upstream hosts number >=2 ,error log:
server.host = 2409:XXXX:XXXX:2000:0:1:afd:7d65:4009 (4009 is port)
server.port = nil
Environment
The text was updated successfully, but these errors were encountered: