Skip to content

HTTPRequestRedirectFilter allows for wildcard hostnames #949

@stevesloka

Description

@stevesloka

What happened:

Looking through the HTTPRequestRedirectFilter spec, the Hostname used has a default kubebuilder validation regex which would allow a user to specify a redirect of *.foo.com which might not make sense as a redirect hostname.

Controllers could catch this and set a condition, we could update the field to use a new hostname type which removes the ability to have a wildcard in the value, or maybe there's a use-case I'm not thinking of that folks would want this?

What you expected to happen:

Hostnames with wildcards would be rejected.

How to reproduce it (as minimally and precisely as possible):

Here's a sample HTTPRoute:

kind: HTTPRoute
apiVersion: gateway.networking.k8s.io/v1alpha2
metadata:
  name: kuard
  namespace: projectcontour
  labels:
    app: kuard
spec:
  parentRefs:
  - group: gateway.networking.k8s.io
    kind: Gateway
    name: contour
  hostnames:
  - "local.projectcontour.io"
  rules:
  - matches:
    - path:
        type: PathPrefix
        value: /
    filters:
      - requestRedirect:
          hostname: "*.stevesloka.com"
          scheme: https
          statusCode: 302
        type: RequestRedirect
    backendRefs:
    - kind: Service
      name: kuard
      port: 80

Right now Contour configures Envoy:

$ curl -i local.projectcontour.io                                                                                                                                 
HTTP/1.1 302 Found
location: https://*.stevesloka.com/
vary: Accept-Encoding
date: Tue, 30 Nov 2021 17:37:35 GMT
server: envoy
content-length: 0

But doesn't route properly:
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/webhookgood first issueDenotes an issue ready for a new contributor, according to the "help wanted" guidelines.help wantedDenotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.kind/bugCategorizes issue or PR as related to a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions