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

https only over ssh reverse proxy does not work #534

Open
blacknon opened this issue Apr 27, 2024 · 1 comment
Open

https only over ssh reverse proxy does not work #534

blacknon opened this issue Apr 27, 2024 · 1 comment

Comments

@blacknon
Copy link

blacknon commented Apr 27, 2024

hello!
Thank you for the nice library!

I'm running an http proxy like reverse dynamic forward, but the http method works but only https doesn't work.
When I specify the listener I created by listening with ssh client and start the Proxy with http.Serve, I am having a hard time because the CONNECT method and subsequent methods do not work.

https://github.com/blacknon/go-sshlib/blob/c11e670601125a5d7d9b33a760b4062388ede9b2/forward.go#L331-L356

// HTTPReverseDynamicForward reverse forwarding http data.
// Like Reverse Dynamic forward (`ssh -R <port>`). but use http proxy.
func (c *Connect) HTTPReverseDynamicForward(address, port string) (err error) {
	// create http proxy. use goproxy
	httpProxy := goproxy.NewProxyHttpServer()

	// set dial
	httpProxy.ConnectDial = func(n, addr string) (net.Conn, error) {
		return net.Dial(n, addr)
	}

	// create listener
	listener, err := c.Client.Listen("tcp", net.JoinHostPort(address, port))
	if err != nil {
		return
	}

	// set logger
	httpProxy.Verbose = true
	httpProxy.Logger = c.getDynamicForwardLogger()

	// listen
	err = http.Serve(listener, httpProxy)
	return
}

If you use net.Listen on the local side instead of on the ssh server side, it will work fine with https.

Is something missing?
I would be grateful if you could give me some advice.

The version used is the master branch as of 2024/04/27.

@blacknon
Copy link
Author

Upon investigation, it appears that the program is getting stuck at the execution of http.Hijacker's Hijack() function. It behaves as if it's waiting, resembling a buffer-like behavior, but it's not clear exactly what's happening.

proxyClient, _, e := hij.Hijack()

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

No branches or pull requests

1 participant