Closed ellisgeek closed 9 months ago
Thanks for opening your first issue here! Be sure to follow the relevant issue templates, or risk having this issue marked as invalid.
For ipv6, you'll have to manually update/edit your resolver.conf
nginx-proxy/nginx-proxy uses the below expression to handle ipv6 resolvers. I was able to patch init-nginx.run
to handle it.
RESOLVERS=$(awk '$1 == "nameserver" {print ($2 ~ ":")? "["$2"]": $2}' ORS=' ' /etc/resolv.conf | sed 's/ *$//g')
Below is a working patch.
--- init-nginx.run.orig 2023-09-04 17:43:42.729804394 -0500
+++ init-nginx.run.sh 2023-09-04 17:53:42.569749584 -0500
@@ -38,18 +38,19 @@
# Set resolver, ignore ipv6 addresses
touch /config/nginx/resolver.conf
if ! grep -q 'resolver' /config/nginx/resolver.conf; then
- RESOLVERRAW=$(awk 'BEGIN{ORS=" "} $1=="nameserver" {print $2}' /etc/resolv.conf)
- for i in ${RESOLVERRAW}; do
- if [[ "$(awk -F ':' '{print NF-1}' <<<"${i}")" -le 2 ]]; then
- RESOLVER="${RESOLVER} ${i}"
- fi
- done
- if [[ -z "${RESOLVER}" ]]; then
- RESOLVER="127.0.0.11"
+ RESOLVERS=$(awk '$1 == "nameserver" {print ($2 ~ ":")? "["$2"]": $2}' ORS=' ' /etc/resolv.conf | sed 's/ *$//g')
+
+ if [[ -z "${RESOLVERS}" ]]; then
+ RESOLVERS="127.0.0.11"
fi
- echo "Setting resolver to ${RESOLVER}"
- RESOLVEROUTPUT="# This file is auto-generated only on first start, based on the container's /etc/resolv.conf file. Feel free to modify it as you wish.\n\nresolver ${RESOLVER} valid=30s;"
- echo -e "${RESOLVEROUTPUT}" >/config/nginx/resolver.conf
+ echo "Setting resolvers to ${RESOLVERS}"
+ RESOLVEROUTPUT="# This file is auto-generated only on first start, based on the container's /etc/resolv.conf file. Feel free to modify it as you wish.\n\n"
+ echo -e "${RESOLVEROUTPUT}" > /config/nginx/resolver.conf
+ for RESOLVER in ${RESOLVERS}; do
+ echo -e "resolver ${RESOLVER} valid=30s;" >> /config/nginx/resolver.conf
+ done
+ echo -e ""
+
fi
# Set worker_processes
I can open an PR to implement this if you'd approve it.
The recommendation doesn't work if an ipv6 resolver with a port is supplied. ex:
nameserver [fdaa::3]:53
results in
[[fdaa::3]:53]
I'm not opposed to considering a working solution for ipv6, but if we're going to change what we have it would be best to have a fairly comprehensive replacement.
This issue has been automatically marked as stale because it has not had recent activity. This might be due to missing feedback from OP. It will be closed if no further activity occurs. Thank you for your contributions.
This issue is locked due to inactivity
Is there an existing issue for this?
Current Behavior
Nginx stalls with the message
nginx: [emerg] invalid port in resolver "fdaa::3" in /config/nginx/resolver.conf:3
when/etc/resolv.conf
contains only ipv6 dns servers.Expected Behavior
/config/nginx/resolver.conf
should be templated correctly with the IPv6 DNS servers enclosed in[]
.Steps To Reproduce
Environment