puma / puma-dev

A tool to manage rack apps in development with puma

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to proxy to another host

kausters opened this issue · comments

Hi!

According to the readme, Puma Dev supports proxying requests to another host which is something I need. However if I try to use it I get an error:

parse 192.168.1.6:8082: first path segment in URL cannot contain colon

Using macOS 10.15.4 and puma-dev 0.13 (go1.13.7)

Any ideas?

Try putting //192.168.1.6:8082 in your app definition file. It know it's funky, but it'll trick url.Parse into working correctly.

It's likely that an older golang version (<1.12) correctly parsed the url without the protocol separator. We should add tests and ensure we accept the x.x.x.x:y format.

puma-dev/dev/app.go

Lines 381 to 401 in 5af3181

u, err := url.Parse(string(data))
if err != nil {
return nil, err
}
var (
sport, host string
port int
)
host, sport, err = net.SplitHostPort(u.Host)
if err == nil {
port, err = strconv.Atoi(sport)
if err != nil {
return nil, err
}
} else {
host = u.Host
}
app.SetAddress(u.Scheme, host, port)

Yeah looks like that worked, thanks!

Adding the // gives me a Bad Gateway response. I've tested that I can get to the IP on that port without puma-dev and it works fine, so the bad gateway occurs within puma-dev. I'd gladly accept some pointers! :D

Figured it out. I needed to be explicit about the scheme, so add http:// to the front of the ip:port.