From c67c0baf10beec9a87b12e85471d1e4b160b3826 Mon Sep 17 00:00:00 2001 From: DJ Gregor Date: Tue, 18 Oct 2022 23:43:07 -0400 Subject: [PATCH] Add DISABLE_IPV6 to ignore AAAA records when proxying requests --- Dockerfile | 3 +++ README.md | 1 + entrypoint.sh | 6 +++++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 3c55f63..f734a20 100644 --- a/Dockerfile +++ b/Dockerfile @@ -117,5 +117,8 @@ ENV PROXY_CONNECT_READ_TIMEOUT="60s" ENV PROXY_CONNECT_CONNECT_TIMEOUT="60s" ENV PROXY_CONNECT_SEND_TIMEOUT="60s" +# Disable use of IPv6 hosts for outbound proxy requests if set to true +ENV DISABLE_IPV6="false" + # Did you want a shell? Sorry, the entrypoint never returns, because it runs nginx itself. Use 'docker exec' if you need to mess around internally. ENTRYPOINT ["/entrypoint.sh"] diff --git a/README.md b/README.md index 25943c7..69d0fe0 100644 --- a/README.md +++ b/README.md @@ -102,6 +102,7 @@ ENV PROXY_REQUEST_BUFFERING="true" - PROXY_CONNECT_READ_TIMEOUT : see [proxy_connect_read_timeout](https://github.com/chobits/ngx_http_proxy_connect_module#proxy_connect_read_timeout) - PROXY_CONNECT_CONNECT_TIMEOUT : see [proxy_connect_connect_timeout](https://github.com/chobits/ngx_http_proxy_connect_module#proxy_connect_connect_timeout) - PROXY_CONNECT_SEND_TIMEOUT : see [proxy_connect_send_timeout](https://github.com/chobits/ngx_http_proxy_connect_module#proxy_connect_send_timeout)) +- Env `DISABLE_IPV6`: If you have problems with `nginx` attempting to connect to hosts over IPv6 but your network doesn't properly support IPv6, set this to `true` to ignore IPv6 AAAA records in DNS responses. ### Simple (no auth, all cache) diff --git a/entrypoint.sh b/entrypoint.sh index 98574ed..8524d34 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -25,7 +25,11 @@ echo "DEBUG, determined RESOLVERS from /etc/resolv.conf: '$RESOLVERS'" conf="" for ONE_RESOLVER in ${RESOLVERS}; do echo "Possible resolver: $ONE_RESOLVER" - conf="resolver $ONE_RESOLVER; " + if [[ "a${DISABLE_IPV6}" == "atrue" ]]; then + conf="resolver $ONE_RESOLVER ipv6=off; " + else + conf="resolver $ONE_RESOLVER; " + fi done echo "Final chosen resolver: $conf"