gateway-api
gateway-api copied to clipboard
How to achieve single hostname with BOTH https and http path
What would you like to be added: Documentation or example about confiuring single hostname with BOTH https and http path. e.g. https://www.example.com/, http://www.example.com/foo
Why this is needed:
How to achieve single hostname with BOTH https and http path, e.g.: "/" with https tcp443 "/plaintext" with http tcp80
Something like:
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: https-redirect
spec:
parentRefs:
- name: gateway-all
namespace: default
sectionName: http
hostnames:
- "www.example.com"
rules:
- filters:
- type: RequestRedirect
requestRedirect:
scheme: https
port: 443
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: http-only
spec:
parentRefs:
- name: gateway-all
namespace: default
sectionName: https
hostnames:
- "www.example.com"
rules:
- matches:
- path:
type: PathPrefix
value: /plaintext
filters:
- type: RequestRedirect
requestRedirect:
scheme: http
port: 80
Hey @e33ivanyauwai, I think I'm having trouble understanding the redirects in your example. If you're attaching a Route exclusively to an HTTP listener, why would you need to redirect to 80 + HTTP?
Thanks for your reply @robscott, our case is that we have a public website with https://example.com, but we also have some API endpoints with http (http://example.com/api) that was feed to a legacy system, we cannot change the code for the legacy system.
I used Nginx Ingress Controller with the below before (with annotation to bypass some path from https), now I migrate to Gateway but it seems I cannot find the documentation about this.
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: project_name-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
nginx.ingress.kubernetes.io/ssl-redirect: "false"
spec:
rules:
- http:
paths:
- path: /
backend:
serviceName: project_name
servicePort: 80
The Kubernetes project currently lacks enough contributors to adequately respond to all issues.
This bot triages un-triaged issues according to the following rules:
- After 90d of inactivity,
lifecycle/staleis applied - After 30d of inactivity since
lifecycle/stalewas applied,lifecycle/rottenis applied - After 30d of inactivity since
lifecycle/rottenwas applied, the issue is closed
You can:
- Mark this issue as fresh with
/remove-lifecycle stale - Close this issue with
/close - Offer to help out with Issue Triage
Please send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle stale
/remove-lifecycle stale