-
Notifications
You must be signed in to change notification settings - Fork 9k
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
swagger-ui: "Try it Now" functionality stripping path prefixes when run behind nginx-ingress reverse proxy in Kubernetes/K8S. #6838
Comments
Hi! Not certain what version of Kubernetes you're using (I'm on Kubernetes 1.20.4 and NGINX Ingress controller v0.44.0),. Adding the
Note: I'm using networking.k8s.io/v1 edit:: Documentation for nginx.ingress.kubernetes.io/x-forwarded-prefix |
@DanSibbernsen |
@80rian Unfortunately my solution doesn't cover that that (for the apps I maintain, we only have 1 path per service, and the only one I cared about for the x-forwarded-prefix was for Swagger). Per this comment, it seems you'd have to define multiple ingresses in order to have different x-forwarded-prefix values passed along. |
Gotcha. Thanks! |
Hi! I tried to pass different
|
@happyincent Thank you very much! |
Someone help solve the problem!Hello. I ran into a similar problem and google brought me to this thread. If I use host-based routing using the address "api.[SomeDomain].com" then everything works fine and I can access the api and SwaggerUI. The example suggested here fom @happyincent - also doesn't work for me. Ingress:
|
same here |
Q&A (please complete the following information)
Content & configuration
roadrunner.acme.co
, and the service is exposed onhttp://roadrunner.acme.com/meep/v1
.hostname/
, rather than a custom path invoking nginx rewrites such ashostname/meep/v1
.meep/v1
in my example).dist/index.html
file so theURL
field points to the OpenAPI spec of my service (i.e.http://roadrunner.acme.co/meep/v1/openapi.json
; the service is a simple Python Flash+Swagger example that auto-exposes theopenapi.json
endpoint).http://roadrunner.acme.co/v1/
rather thanhttp://roadrunner.acme.co/meep/v1
(i.e. the re-written portion of the URL is absent).Example ingress:
Example Swagger/OpenAPI definition: N/A.
Swagger-UI configuration options:
Describe the bug you're encountering
To reproduce...
Example described above.
Expected behavior
X-Forwarded-For
or additional parameters supplied to the ingress-controller, so that re-writes don't break functionality).Additional context or thoughts
There's a hack I've figured out in order to make the "Try It Now" ==> "Execute" functionality work, but the downside (severe), is that I need to supply the external hostname to the swagger-ui app at chart installation time (i.e. when I install swagger-ui, it needs to be provided with the string
http://roadrunner.acme.co/meep/v1
at installation time). This isn't a permanent/viable solution though, as various users may "see" a different hostname and base path when accessing this micro-service (e.g. if it's exposed via multiple domains with a common load balancer, or if some people attempt to access it via IP address rather than this specific host name). It also prevents 100% end-to-end automated installation, as someone needs to supply the external FQDN + base path at chart installation time.Hack-y workaround:
kubectl apply --namespace=acme-ns -f ingress-meep.yaml
.ingress-meep.yaml
kubectl apply --namespace=acme-ns -f ingress-demo.yaml
.ingress-demo.yaml
<http://roadrunner.acme.co/swagger-demo/>
in my browser. Application loads and is visible in my browser.v1
tohttp://roadrunner.acme.co/meep/v1
. Both the general UI features, and the live debug "Try It Now" features work as expected.Possibly related issues (external projects)
The text was updated successfully, but these errors were encountered: