Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to proxy to another host #252

Open
kausters opened this issue Jun 5, 2020 · 4 comments
Open

Unable to proxy to another host #252

kausters opened this issue Jun 5, 2020 · 4 comments

Comments

@kausters
Copy link

kausters commented Jun 5, 2020

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?

@nonrational
Copy link
Member

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)

@nonrational nonrational added the bug label Jun 5, 2020
@kausters
Copy link
Author

kausters commented Jun 8, 2020

Yeah looks like that worked, thanks!

@brendon
Copy link

brendon commented Mar 20, 2023

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

@brendon
Copy link

brendon commented Mar 20, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants