gofiber / fiber

⚡️ Express inspired web framework written in Go

Home Page:https://gofiber.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

ganlvtech opened this issue · comments

commented

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) 
} 

req.SetRequestURI(utils.UnsafeString(req.RequestURI()))

copiedURL := utils.CopyString(addr)
req.SetRequestURI(copiedURL)
// 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)
}

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