Skip to content

Swagger UI does not work in a kubernetes nginx-ingress setup #534

Closed
@gjgarryuan

Description

@gjgarryuan

I don't think this is a bug on the springdoc's side, but rather some unusability with the setup of kubernetes nginx-ingress + webapp with springdoc.

The observation is as follows:

  1. Browser visits https://some-host-name/some/path/prefix/swagger-ui.html
  2. Browser gets back HTTP 307 to redirect to /webjars/swagger-ui/index.html?configUrl=/v3/api-docs/swagger-config
  3. Browser visits https://some-host-name/webjars/swagger-ui/index.html?configUrl=/v3/api-docs/swagger-config

As step 3 above, the configured nginx-ingress does not recognize the path as it does not start with the /some/path/prefix, hence redirect the request to the nginx home page.

The nginx-ingress is configured with:

{
    "apiVersion": "extensions/v1beta1",
    "kind": "Ingress",
    "metadata": {
        "annotations": {
            "kubernetes.io/ingress.class": "nginx-private",
            "nginx.ingress.kubernetes.io/rewrite-target": "/$2"
        },
        "name": "some-ingress",
        "namespace": "some-namespace"
    },
    "spec": {
        "rules": [
            {
                "host": "some-host-name",
                "http": {
                    "paths": [
                        {
                            "backend": {
                                "serviceName": "webapp-service",
                                "servicePort": 80
                            },
                            "path": "/some/path/prefix(/|$)(.*)"
                        }
                    ]
                }
            }
        ]
    }
}

I'm not sure if you have any solution for this kind of setup?

Screenshots
Screen Shot 2020-04-02 at 8 58 34 PM

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions