Skip to content
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

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

Open
simhnna opened this issue Mar 10, 2025 · 1 comment
Labels
kind/feature Categorizes issue or PR as related to a new feature. needs-priority needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one.

Comments

@simhnna
Copy link

simhnna commented Mar 10, 2025

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)

@simhnna simhnna added the kind/feature Categorizes issue or PR as related to a new feature. label Mar 10, 2025
@k8s-ci-robot k8s-ci-robot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Mar 10, 2025
@k8s-ci-robot
Copy link
Contributor

This issue is currently awaiting triage.

If Ingress contributors determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature. needs-priority needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one.
Projects
Development

No branches or pull requests

2 participants