Support for hexadecimal or octal ip format for the proxy_pass module

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:
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.


On Sun, Jan 31, 2010 at 06:17:31PM +0100, Dalaih wrote:

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
% 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
% grammar.

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 This isn’t what people
    may expect.

  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

Probably these two issues should be addressed.

Maxim D.

On Sun, Jan 31, 2010 at 06:17:31PM +0100, Dalaih wrote:

Why ?

Igor S.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs