Support for hexadecimal or octal ip format for the proxy_pass module
mdounin at mdounin.ru
Tue Feb 2 01:38:44 MSK 2010
On Sun, Jan 31, 2010 at 06:17:31PM +0100, Dalaih wrote:
> I'd like the proxy_pass module of nginx to be able to support hexadecimal or
> octal ip formats.
> For example here are the different versions of the ip of the nginx forum :
> IP address: http://184.108.40.206
> Hexadecimal: http://0xae245e10
> Octal (dotted): http://0256.044.0136.020
> Octal (undotted): http://2921618960
> As you can see, they all work fine in any "civilized" browsers
> Thanks in advance for your help.
Hexadecimal, octal and so on forms aren't standard. HTTP 1.1 RFC
2616 refers to RFC 2396, which says:
% The host is a domain name of a network host, or its IPv4 address as a
% set of four decimal digit groups separated by ".".
And RFC 3986 (which is newer version of RFC 2396) explicitly
mentions such addresses in section 3.2.2:
% Note that other forms of dotted notation may
% be interpreted on some platforms, as described in Section 7.4, but
% only the dotted-decimal form of four octets is allowed by this
and further clarifies this in section 7.4, see here:
I see nothing wrong in not supporting such addresses. The bad
thing is that nginx has two problems with such addresses right
1. It doesn't handle leading 0 specially, therefore addresses like
"0127.0.0.1" will be parsed as 127.0.0.1. This isn't what people
2. In some places during config parsing nginx fallbacks to
gethostbyname() when it's unable to interpret address as ip
literal, and gethosbyname() in it's turn tries to interpret ip
literals according to it's own rules. So address like "0127.1"
will be parsed (at least on some systems) as 220.127.116.11.
Probably these two issues should be addressed.
More information about the nginx