# Does url resolve support ipv6?

**URL:** <https://www.ruby-forum.com/t/does-url-resolve-support-ipv6/203478>\
**Category:** NGINX\
**Created:** [February 21, 2011, 8:48am UTC](https://www.ruby-forum.com/t/does-url-resolve-support-ipv6/203478 "2011-02-21T08:48:52Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [February 21, 2011, 8:48am UTC](https://www.ruby-forum.com/t/does-url-resolve-support-ipv6/203478/1 "2011-02-21T08:48:52Z")

</div>

I have several upstream servers, which are configured like this:

upstream backend {  
ip\_hash;  
server [backend1.example.com](http://backend1.example.com);  
server [backend2.example.com](http://backend2.example.com);  
server [backend3.example.com](http://backend3.example.com) down;  
server [backend4.example.com](http://backend4.example.com);  
}

each server has ONLY IPv6 address. But seems nginx can’t parse it to  
that address, and report an error like this “[error] host not found”.

Is this a bug or meant not to be supported yet?

Posted at Nginx Forum:

> **[Does url resolve support ipv6?](https://forum.nginx.org/read.php?2,177146,177146#msg-177146)**
>
> I have several upstream servers, which are configured like this: upstream backend { ip\_hash; server backend1.example.com; server backend2.example.com; server backend3.example.com down; server backend4.example.com; }

---

<div class="post-metadata">

**Author:** ![speedfirst](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e19adc/32.png) [@speedfirst](https://www.ruby-forum.com/u/speedfirst)\
**Post date:** [February 21, 2011, 8:57am UTC](https://www.ruby-forum.com/t/does-url-resolve-support-ipv6/203478/2 "2011-02-21T08:57:39Z")

</div>

I check the code and find it uses “ngx\_parse\_url” and this function  
first try to find whether there is a “[” in the first character to judge  
whether use ipv4 or ipv6 parse. This is clearly wrong because you can’t  
tell the URL’s ip address type.

I’d like to write a patch to improve this.

Posted at Nginx Forum:

> **[Re: Does url resolve support ipv6?](https://forum.nginx.org/read.php?2,177146,177149#msg-177149)**
>
> I have several upstream servers, which are configured like this: upstream backend { ip\_hash; server backend1.example.com; server backend2.example.com; server backend3.example.com down; server backend4.example.com; }

---

<div class="post-metadata">

**Author:** ![speedfirst](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e19adc/32.png) [@speedfirst](https://www.ruby-forum.com/u/speedfirst)\
**Post date:** [February 21, 2011, 11:22am UTC](https://www.ruby-forum.com/t/does-url-resolve-support-ipv6/203478/3 "2011-02-21T11:22:52Z")

</div>

Hi,

i had a similar problem with the proxy module and, i think it was  
Igor himself who told me, that there is currently no ipv6 support  
for the proxy module. So it might be the same issue here.

HTH,  
Sven

Am 21.02.2011 08:46, schrieb speedfirst:

---

<div class="post-metadata">

**Author:** ![speedfirst](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e19adc/32.png) [@speedfirst](https://www.ruby-forum.com/u/speedfirst)\
**Post date:** [February 21, 2011, 1:08pm UTC](https://www.ruby-forum.com/t/does-url-resolve-support-ipv6/203478/4 "2011-02-21T13:08:17Z")

</div>

Hello!

On Mon, Feb 21, 2011 at 02:46:30AM -0500, speedfirst wrote:

> each server has ONLY IPv6 address. But seems nginx can’t parse it to  
> that address, and report an error like this “[error] host not found”.
> 
> Is this a bug or meant not to be supported yet?

IPv6 currently only supported in listen directive. That is, there  
is more than one issue when trying to proxy to IPv6 addresses.

Maxim D.

---

<div class="post-metadata">

**Author:** ![speedfirst](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e19adc/32.png) [@speedfirst](https://www.ruby-forum.com/u/speedfirst)\
**Post date:** [February 22, 2011, 6:08am UTC](https://www.ruby-forum.com/t/does-url-resolve-support-ipv6/203478/5 "2011-02-22T06:08:52Z")

</div>

that function call is blocking isnt it?

---

<div class="post-metadata">

**Author:** ![speedfirst](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e19adc/32.png) [@speedfirst](https://www.ruby-forum.com/u/speedfirst)\
**Post date:** [February 22, 2011, 3:15am UTC](https://www.ruby-forum.com/t/does-url-resolve-support-ipv6/203478/6 "2011-02-22T03:15:11Z")

</div>

If I only concern about the proxy of http upstream and mail upstream, is  
it alright to change the implementation of “ngx\_parse\_url”, which  
replace “gethostbyname” to “getaddrinfo”? Is there other issues that I  
need to pay attention?

Posted at Nginx Forum:

> **[Re: Does url resolve support ipv6?](https://forum.nginx.org/read.php?2,177146,177392#msg-177392)**
>
> I have several upstream servers, which are configured like this: upstream backend { ip\_hash; server backend1.example.com; server backend2.example.com; server backend3.example.com down; server backend4.example.com; }

---

<div class="post-metadata">

**Author:** ![speedfirst](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e19adc/32.png) [@speedfirst](https://www.ruby-forum.com/u/speedfirst)\
**Post date:** [February 22, 2011, 6:14am UTC](https://www.ruby-forum.com/t/does-url-resolve-support-ipv6/203478/7 "2011-02-22T06:14:28Z")

</div>

Hi,

> that function call is blocking isnt it?

So is gethostbyname().

Best regards,  
Piotr S. \< [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) \>
