-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Attaching Echo instance to multiple ports does not work #1785
Comments
Could you provide example how your Echo is setup and started? Especially how your HTTP server/listener and HTTPS server/listener are setup with Echo instance. Can you replicate redirect loop with command line tools? I'm asking this because if you are using javascript in frontend your JS implementation could cause that loop. JS in browser decides to direct user to HTTP and Echo (or whatever loadbalancer Nginx/Apache etc you have in front of echo instance) redirects user back to HTTPS from HTTP |
I don't have Nginx/Apache upfront with the application at this moment. Set up:
Also, I use prerouting
Call with curl -v to my test server. As you can see the call is not redirected (so actually I was wrong with the loop, it just didn't hit redirect or response)
A sample response from production after downgrade
|
@maciej-jezierski problem here is that you are attaching Echo multiple times to same If you want to serve on multiple ports you need to use at least For example: func TestHTTPS_redirect(t *testing.T) {
createEcho := func() *echo.Echo {
e := echo.New()
e.Pre(middleware.HTTPSRedirect())
e.Pre(middleware.HTTPSNonWWWRedirect())
e.Use(middleware.RemoveTrailingSlashWithConfig(middleware.TrailingSlashConfig{
RedirectCode: http.StatusMovedPermanently,
}))
e.Use(middleware.GzipWithConfig(middleware.GzipConfig{
Level: 2,
}))
e.Use(middleware.Recover())
e.Use(middleware.SecureWithConfig(middleware.SecureConfig{
ReferrerPolicy: "no-referrer",
}))
e.Use(func(next echo.HandlerFunc) echo.HandlerFunc {
return func(c echo.Context) error {
if strings.HasSuffix(c.Request().Host, ".webkomiksy.pl") {
return c.Redirect(http.StatusMovedPermanently, "https://webkomiksy.pl")
}
return next(c)
}
})
return e
}
go func() {
http := createEcho()
http.Logger.Fatal(http.Start(":1321"))
}()
https := createEcho()
https.Logger.Fatal(https.StartTLS(":1323", "_fixture/certs/cert.pem", "_fixture/certs/key.pem"))
} |
Thanks, will test it in the next iteration |
…lready TLSListener set to Echo instance. (labstack#1785) This is problem when user tries to use HTTP (e.Listener) and HTTPS (e.TLSListener) with same Echo instance.
…lready TLSListener set to Echo instance. (labstack#1785) This is problem when user tries to use HTTP (e.Listener) and HTTPS (e.TLSListener) with same Echo instance.
Fixed in master with PR #1793. This is now possible without modifications |
Hi all, I've done the upgrade from 4.1.15 to 4.2.0. I noticed HTTP redirect to HTTPS is running in a cycle and never happens. Also noticed by my website users.
The text was updated successfully, but these errors were encountered: