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

Allow stripping of path-prefix in a portable way #5197

Closed
micw opened this issue Feb 28, 2020 · 2 comments
Closed

Allow stripping of path-prefix in a portable way #5197

micw opened this issue Feb 28, 2020 · 2 comments
Labels
kind/feature Categorizes issue or PR as related to a new feature.

Comments

@micw
Copy link

micw commented Feb 28, 2020

I'd like to strip paths for forwarded URIs in a way that is compatible with other ingress controllers.

Example:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /$1
  name: test
spec:
  rules:
  - host: test.example.com
    http:
      paths:
      - backend:
          serviceName: test
          servicePort: http
        path: /something/(.*)

This maps /something to / on the backend service. It works pretty well with nginx but the regular expression on the path breaks compatibility with other ingress controllers (e.g. traefik 1+2).
The expression part is required because it generates the following config:

rewrite "(?i)/something/(.*)" /$1 break;

Without the expression part, $1 is not available for rewrite.

Possible solutions:
Variant1: always add (.?) at the end of the 1st rewite parameter
Variant1a: add an annotation to enable Variant1
Variant1b: add (.
?) at the end of the 1st rewite parameter if the 2nd parameter uses $1 but there's no capture group on the 1st parameter
Variant2: add an annotation that allows to override the 1st rewite parameter

Personally I see Variant1b as the best solution. It does not break any existing deployments and adds the requested feature without any additional annotations.

/kind feature

@micw micw added the kind/feature Categorizes issue or PR as related to a new feature. label Feb 28, 2020
@aledbf
Copy link
Member

aledbf commented Feb 29, 2020

@micw unfortunately, this is something we already tried in the past for the path field.
Please check #555 and #4989.

For that reason, I am closing this issue.

@aledbf aledbf closed this as completed Feb 29, 2020
@micw
Copy link
Author

micw commented Mar 8, 2020

@aledbf It seems that #555 was closed after the discussion lost focus. My proposal above would be an easy way to solve 90% of the portability issues with a minimal code change. Would you be open to talk about it?

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.
Projects
None yet
Development

No branches or pull requests

2 participants