From: Kasper Johansen Date: 2010-12-25T19:29:20+09:00 Subject: [ruby-core:33872] Bug in Webrick httprequest.rb using multiple proxies and fix This is a MIME-formatted message. If you see this text it means that your E-mail software does not support MIME-formatted messages. --=_kaspernj.org-1132-1293272961-0001-2 Content-Type: text/plain; charset=iso-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hi. This is my first post to this mailing list, so please tell me, if I posted this the wrong place, or I in any other way should do something different. I have been playing around with Webrick for some time now, and decided to set up a virtual machine with a hosted webrick based application. For every request, the request goes through two Apache proxies because of lack of IP adresses. The forwarded hostname is therefore split by commas like this: Host= domain.com, someotherdomainoorip.com Webrick doesnt handle this well. It looks like it only supports one single forwarded hostname. This can however easily be fixed by changing like 291 in httprequest.rb from: host, port = @forwarded_host, @forwarded_port To: host, port = @forwarded_host.split(",")[0].strip, @forwarded_port If not, Webrick will not handle the request and raise an error. My fix may be more than a hack than a fix, but for now it works and makes Webrick actually handle the request instead of crashing. I have attached a .diff I made with Subversion. Thank you for a great programming language. -- Kasper Johansen --=_kaspernj.org-1132-1293272961-0001-2 Content-Type: text/x-patch; name="webrick_httprequest_multiple_proxy_fix.diff"; charset=iso-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="webrick_httprequest_multiple_proxy_fix.diff" Index: lib/webrick/httprequest.rb =================================================================== --- lib/webrick/httprequest.rb (revision 30363) +++ lib/webrick/httprequest.rb (working copy) @@ -288,7 +288,7 @@ uri = URI::parse(str) return uri if uri.absolute? if @forwarded_host - host, port = @forwarded_host, @forwarded_port + host, port = @forwarded_host.split(",")[0].strip, @forwarded_port elsif self["host"] pattern = /\A(#{URI::REGEXP::PATTERN::HOST})(?::(\d+))?\z/n host, port = *self['host'].scan(pattern)[0] --=_kaspernj.org-1132-1293272961-0001-2--