Forum: NGINX Support for hexadecimal or octal ip format for the proxy_pass module

Posted by Dalaih (Guest)
on 2010-02-01 21:35
(Received via mailing list)
Hello,
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://174.36.94.16
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
(firefox...etc).
Thanks in advance for your help.
Posted by Maxim Dounin (Guest)
on 2010-02-01 23:39
(Received via mailing list)
Hello!

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

> (firefox...etc).
> 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
%   grammar.

and further clarifies this in section 7.4, see here:

http://tools.ietf.org/html/rfc3986#section-7.4

I see nothing wrong in not supporting such addresses.  The bad
thing is that nginx has two problems with such addresses right
now:

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

Probably these two issues should be addressed.

Maxim Dounin
Posted by Igor Sysoev (Guest)
on 2010-02-02 13:48
(Received via mailing list)
On Sun, Jan 31, 2010 at 06:17:31PM +0100, Dalaih wrote:

> (firefox...etc).
Why ?


--
Igor Sysoev
http://sysoev.ru/en/
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.