Open caiofct opened 1 year ago
I've run some tests locally and discovered that rack 2.1.4.3 parses the request correctly:
irb(main):001:0> gem 'rack', '=2.1.4.3'
irb(main):002:0> require 'rack'
irb(main):003:0> r = Rack::Request.new({"HTTP_HOST" => "some_service:3001"})
irb(main):004:0> r.port
=> 3001
So it seems rack 2.2.6.4 introduced some regressions here. I've created an issue there https://github.com/rack/rack/issues/2070 so we have better tracking. Let me know if we should close this issue or if there's any workarounds on rack-proxy's side I could try.
We were using this gem for a while and never had problems with it, however, after we upgraded rack from 2.1.4.3 to 2.2.6.4 we started observing some issues with the way this gem parses a
Rack:Request
. It's important to note that this only happens when running the app through docker.In our Proxy we do:
The
PROXY_URL
env var has a value ofsome_service:3001
. And when trying to access thehttp://localhost:3000/some_service
path we get an error:Failed to open TCP connection to some_service:3001:80 (getaddrinfo: Name or service not known)
. After spending some time investigating this it seems the issue is with the way aRack::Request
is being parsed. Not sure if this is an issue with rack or on this gem's code. But wanted to point out something:The code above is for rack 2. Rack 3 seems to handle the host parsing a lot better however setting a
SERVER_PORT
should have worked but actually didn't. So I'm clueless and would like to know if anyone here has any ideas or have experienced something similar.Also I'm intrigued by the fact that we were using the same rack-proxy version of 0.7.6 with rack 2.1.4.3 for a while and didn't have any issues. Which leads me to believe this might be a regression from: https://github.com/rack/rack/pull/1606 which was backported to 2.2.6.4.
Rails version: 7.0.4 Ruby: 2.7.8 rack-proxy: 0.7.6 rack: 2.2.6.4