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

How to achieve single hostname with BOTH https and http path #2991

Open
e33ivanyauwai opened this issue Apr 18, 2024 · 2 comments
Open

How to achieve single hostname with BOTH https and http path #2991

e33ivanyauwai opened this issue Apr 18, 2024 · 2 comments
Labels
kind/documentation Categorizes issue or PR as related to documentation.

Comments

@e33ivanyauwai
Copy link

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
@e33ivanyauwai e33ivanyauwai added the kind/documentation Categorizes issue or PR as related to documentation. label Apr 18, 2024
@robscott
Copy link
Member

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?

@e33ivanyauwai
Copy link
Author

e33ivanyauwai commented Apr 19, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/documentation Categorizes issue or PR as related to documentation.
Projects
None yet
Development

No branches or pull requests

2 participants