Skip to content

Ability to serve webapps with rewrite target under subpaths while appending slashes #12966

@simhnna

Description

@simhnna

The following is an ingress from the docs with an added rewrite rule to append a slash

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    nginx.ingress.kubernetes.io/use-regex: "true"
    nginx.ingress.kubernetes.io/rewrite-target: /$2
    nginx.ingress.kubernetes.io/configuration-snippet: |
      rewrite ^(/something)$ " $1/" permanent;
  name: rewrite
  namespace: default
spec:
  ingressClassName: nginx
  rules:
  - host: rewrite.bar.com
    http:
      paths:
      - path: /something(/|$)(.*)
        pathType: ImplementationSpecific
        backend:
          service:
            name: http-svc
            port: 
              number: 80

The ingress can be summarized as following:

  • serve webapp under /something/
  • redirect /something to /something/
  • rewrite target stripping /something

We're currently in the process of phasing out configuration-snippet but we don't know how to best accomplish the combination of the three points above.

  • We're fine with having ImplementationSpecific paths, so something like http://nginx.ingress.kubernetes.io/app-root that works for all paths would be ok
  • If we can somehow strip the prefix while using Prefix paths even better (they should autoredirect appending the slash out of the box)
  • We could do the redirect in our own applications, but we can't do that for third party software
  • We'd like to avoid declaring duplicate ingresses that redirect appending slashes

Note: I've posted about this in slack but didn't get a solution there (yet)

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/featureCategorizes issue or PR as related to a new feature.lifecycle/frozenIndicates that an issue or PR should not be auto-closed due to staleness.needs-priorityneeds-triageIndicates an issue or PR lacks a `triage/foo` label and requires one.

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions