kubernetes-sigs / gateway-api

Repository for the next iteration of composite service (e.g. Ingress) and load balancing APIs.
https://gateway-api.sigs.k8s.io
Apache License 2.0
1.84k stars 480 forks source link

question about HTTP to HTTPS redirects #3356

Closed lukassup closed 1 month ago

lukassup commented 1 month ago

At the moment creating HTTP to HTTPS redirects feel a bit complicated - you need to reference a listener sectionName in the Gateway and create 2 HTTPRoutes - one for redirecting to HTTPS, one for actual proxying of the traffic.

Would it make sense allowing to match on scheme and apply redirect filter?

apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: my-httproute
spec:
  parentRefs:
  - name: my-gateway
  hostnames:
  - mydomain.com
  rules:
  # one rule to match on scheme & apply redirect filter
  - matches:
    - scheme: http
    filters:
    - type: RequestRedirect
      requestRedirect:
        scheme: https
  # another rule to route traffic to backend
  - backendRefs:
    - name: my-svc
      port: 80
arkodg commented 1 month ago

dup of https://github.com/kubernetes-sigs/gateway-api/issues/2809