Reverse Proxy configuration
lucasoares opened this issue · comments
Hello.
I use a reverse proxy (Istio+Envoy) and I'm unable to configure swagger using fiber correctly.
I'm configuring the swagger handler like this:
app.Get("/docs/*", swagger.HandlerDefault)
But when I try to access it from the proxy, which is a URL like this:
https://proxy-host/some/custom/path/docs
The current implementation redirects me to:
https://proxy-host/docs/index.html
Instead of
https://proxy-host/some/custom/path/docs/index.html
The Try it out
button also doesn't works because it is trying to send the request to the incorrect path. It should send the request to https://my-proxy-host/custom/path/channels
.
Also, TrustedProxies
and EnableTrustedProxyCheck
options don't fix this issue. And even it could fix my reverse proxy doesn't have a fixed IP, which would be impossible to configure using the available options. I think you guys should look how Spring Boot manages this and maybe this is even a fiber
issue (fixing the c.Redirect
func) instead of a gofiber swagger
issue: https://docs.spring.io/spring-boot/docs/current/reference/html/howto.html#howto.webserver.use-behind-a-proxy-server
Thanks.
@arsmn have you a clue? Can you take over ?
Have not much experience with the swagger middleware.
Sure. I will check it ASAP.
I made it work changing how the redirect is made in #4
For the "Try it out" button, I just set in my own application the basePath
of the swag's docs.SwaggerInfo.BasePath
which brings another issue. If I atempt to access this documentation using Pod's (I'm using kubernetes) direct IP, the "Try it out" button will also not work. Maybe we should change how gofiber swagger deliver the doc.json
changing its basePath
dinamically?
For the PR itself the only change I think may be necessary is to change to not compute prefix onle once, since the first access will define its value and I may have accesses from different sources in an application (proxy, pod's direct IP, etc).
Also, what is the difference between this repository, swaggo/fiber-swagger and gofiber/contrib/?
Also @ReneWerner87 @arsmn this is definitely not a question-issue. It is a BUG or at least a feature request.