fiber icon indicating copy to clipboard operation
fiber copied to clipboard

proxy.Balancer middleware should handle http backend servers when using app.ListenTLS

Open ganlvtech opened this issue 9 months ago • 1 comments

need add req.URI().SetScheme("http") in proxy.Balancer

req.SetRequestURI(utils.UnsafeString(req.RequestURI())) 
// NOTE: if req.isTLS is true, SetRequestURI keeps the scheme as https. 
// Reference: https://github.com/gofiber/fiber/issues/1762 
if scheme := getScheme(utils.UnsafeBytes(copiedURL)); len(scheme) > 0 { 
	req.URI().SetSchemeBytes(scheme) 
} 

https://github.com/gofiber/fiber/blob/109ccdd4adbaf604c12186c41a2060f0eaf4424a/middleware/proxy/proxy.go#L80-L81

https://github.com/gofiber/fiber/blob/109ccdd4adbaf604c12186c41a2060f0eaf4424a/middleware/proxy/proxy.go#L180-L186

ganlvtech avatar May 09 '24 11:05 ganlvtech

Thanks for opening your first issue here! 🎉 Be sure to follow the issue template! If you need help or want to chat with us, join us on Discord https://gofiber.io/discord

welcome[bot] avatar May 09 '24 11:05 welcome[bot]

I moved to fasthttp.Client insteadof HostClient. HTTP requests are OK, but WebSocket requests won't be forwarded.

ganlvtech avatar May 28 '24 12:05 ganlvtech