-
Notifications
You must be signed in to change notification settings - Fork 171
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
Proxy won't fallback to IPv4 when IPv6 is not available #108
Comments
Hello, as you figured we do very little except point nginx to the default resolvers if not specified. Otherwise poke around Docker, if the machine is IPv4, why is it returning AAAA records? |
Hi rpardini! and thanks for the quick response 😄 I don't think it has anything to do with docker itself, because as much as I understand, Nginx has its own implementation of the DNS query. https://stackoverflow.com/a/40331256/10574201 If the behavior is really caused by Nginx internal implementation and cannot be changed, maybe it's a good idea to add some env var to control the usage of IPv6, or add to the documentation how to use a custom resolver to control it? |
Yes. I'm hoping future versions of nginx will be more standard regarding 1) name resolutions and 2) ipv6 port binding, which requires special syntax. Feel free to PR docs as well. |
This worked like a charm |
The issue
I encountered an issue when building one of my Dockerfiles on a host that uses the proxy (version 0.6.4).
The Dockerfile tries to run
curl "https://www.random.org/cgi-bin/randbyte?nbytes=10&format=h"
, but half of the times it getscurl: (56) Received HTTP code 502 from proxy after CONNECT
from the proxy server.After some investigation, I found out that the DNS address
www.random.org
leads to 4 IP addresses, 2 are IPv4 and 2 are IPv6.When it failed, this was the log in the proxy:
It seems like the error happens when the proxy tried to access one of the IPv6 addresses, which makes sense because my host only has an IPv4 address.
I expected that when the IPv6 leads to "Network unreachable", the Nginx will fall back to the IPv4 and run the query (just like the normal behavior of the
curl
command), but instead is just returns "502 Bad Gateway".Is it possible to make it happen?
If not, maybe at least add an environment variable that controls the usage of IPv6, so it will be easier to disable?
Steps to reproduce
sudo docker run -d --name docker_registry_proxy -p 0.0.0.0:3128:3128 rpardini/docker-registry-proxy:0.6.4
curl --proxy http://localhost:3128 "https://www.random.org/cgi-bin/randbyte?nbytes=10&format=h"
curl: (56) Received HTTP code 502 from proxy after CONNECT
about half of the timesExpected behavior
The request should be successful all the time, just like when the proxy is not used (
curl "https://www.random.org/cgi-bin/randbyte?nbytes=10&format=h"
)Workaround
After exploring the project's code, I managed to disable the usage of IPv6 by creating a file named
resolvers.conf
that containsAnd mount it to the container with
-v /home/ubuntu/resolvers.conf:/etc/nginx/resolvers.conf
This makes the Nginx not resolve DNS records to IPv6 addresses at all.
Thanks in advance!
The text was updated successfully, but these errors were encountered: