Opened 3 years ago
Closed 3 years ago
#2308 closed defect (duplicate)
proxy_bind and proxy_pass address family mismatch causes connection fail
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | minor | Milestone: | |
Component: | nginx-core | Version: | |
Keywords: | Cc: | ||
uname -a: | Linux lukas 5.16.1-arch1-1 #1 SMP PREEMPT Sun, 16 Jan 2022 11:39:23 +0000 x86_64 GNU/Linux | ||
nginx -V: |
nginx version: nginx/1.20.2
built with OpenSSL 1.1.1l 24 Aug 2021 (running with OpenSSL 1.1.1m 14 Dec 2021) TLS SNI support enabled configure arguments: --prefix=/etc/nginx --conf-path=/etc/nginx/nginx.conf --sbin-path=/usr/bin/nginx --pid-path=/run/nginx.pid --lock-path=/run/lock/nginx.lock --user=http --group=http --http-log-path=/var/log/nginx/access.log --error-log-path=stderr --http-client-body-temp-path=/var/lib/nginx/client-body --http-proxy-temp-path=/var/lib/nginx/proxy --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-cc-opt='-march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection' --with-ld-opt=-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now --with-compat --with-debug --with-file-aio --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_degradation_module --with-http_flv_module --with-http_geoip_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-pcre-jit --with-stream --with-stream_geoip_module --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-threads |
Description
When using a hostname in proxy_pass, this hostname is effectively resolved to either an IPv4 or an IPv6 address. If proxy_bind contains a local address of the other family, an error like these occurs:
[crit]: *1 bind(0.0.0.0) failed (22: Invalid argument) while connecting to upstream
[crit]: *1 bind(::) failed (97: Address family not supported by protocol) while connecting to upstream
nginx already queries both the A and AAAA records, but for actual connection establishment, it needs to choose the record type matching to the proxy_bind address family.
If the proxy_bind address is IPv4 and hostnames are resolved dynamically, ipv6=off can be set in the resolver as a workaround, but there is no ipv4=off option for IPv6 proxy_bind addresses.
This bug can be reproduced in http and stream. A config file for reproducing this bug is attached.
Attachments (1)
Change History (3)
by , 3 years ago
Attachment: | nginx.conf added |
---|
comment:1 by , 3 years ago
comment:2 by , 3 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
As already found out by the reporter, duplicate of #1535.
Duplicate of https://trac.nginx.org/nginx/ticket/1535