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

Same Path, multiple ports #11334

Closed
Leonardo-Ferreira opened this issue Apr 30, 2024 · 5 comments
Closed

Same Path, multiple ports #11334

Leonardo-Ferreira opened this issue Apr 30, 2024 · 5 comments
Labels
needs-kind Indicates a PR lacks a `kind/foo` label and requires one. needs-priority needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one.

Comments

@Leonardo-Ferreira
Copy link

I need my API hosted in AKS to respond in ports 80 and 443. In port 80 because some of my current clients are using port 80 "hardcoded" and their HttpClients do not follow redirects...

my first try was:

apiVersion: v1
kind: Service
metadata:
  name: myApp-service
  namespace: myAppe-main
  labels:
    app: myApp-service
spec:
  ports:
    - port: 80
      targetPort: 80
      protocol: TCP
      name: http
    - port: 443
      targetPort: 443
      protocol: TCP
      name: https
  selector:
    app: myApp-deploy
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: myApp-ingress
  namespace: myApp-main
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/backend-protocol: H2C
    nginx.ingress.kubernetes.io/secure-backends: 'true'
    nginx.ingress.kubernetes.io/ssl-passthrough: 'true'
spec:
  rules:
    - host: myApp.MyInternalDns.net
      http:
        paths:
          - backend:
              service:
                name: myApp-service
                port:
                    number: 80
            path: /
            pathType: Prefix
      https:
        paths:
          - backend:
              service:
                name: myApp-service
                port:
                    number: 443
            path: /
            pathType: Prefix

Although AKS accepts this yaml, it chops off the https part of it...

How can I make the ingress open both ports and have it working on http and https?

I found this #1655 but AKS is not accepting v1beta1...

@k8s-ci-robot
Copy link
Contributor

This issue is currently awaiting triage.

If Ingress contributors determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-kind Indicates a PR lacks a `kind/foo` label and requires one. needs-priority labels Apr 30, 2024
@longwuyuan
Copy link
Contributor

You have not provided the information asked in the template of a new bug report. Click the new bug report button and look at the questions asked. Then don't create a new issue but edit this issue description and anwer the questions asked in md format. Once satisfied, then re-open the issue

Generally you will need to create 2 ingresses with different hostnames. One terminated with TLS and the other no tls section.

if you mean to use HTTPS to the backend pod itself then, this controller has a backend-protocol annotation but I don't think you are using this controller.

Also ssl-passthrough does not combine with port 80 obviously

/close

/close

@k8s-ci-robot
Copy link
Contributor

@longwuyuan: Closing this issue.

In response to this:

You have not provided the information asked in the template of a new bug report. Click the new bug report button and look at the questions asked. Then don't create a new issue but edit this issue description and anwer the questions asked in md format. Once satisfied, then re-open the issue

Generally you will need to create 2 ingresses with different hostnames. One terminated with TLS and the other no tls section.

if you mean to use HTTPS to the backend pod itself then, this controller has a backend-protocol annotation but I don't think you are using this controller.

Also ssl-passthrough does not combine with port 80 obviously

/close

/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

kvaps added a commit to aenix-io/cozystack that referenced this issue Jul 26, 2024
We need to separate HTTP and HTTPS traffic and send them into tenant
clusters.
Currently traffic was sending only on HTTPS port, this PR enables HTTP
traffic forwarding.

Nginx ingress does not support setting correct upstream according to
type of traffic (http or https)
There are set of issues in upstream.

- kubernetes/ingress-nginx#1655
- kubernetes/ingress-nginx#9061
- kubernetes/ingress-nginx#11334

Good to know that we found reliable workaround

fixes:
#209 (comment)
@kvaps
Copy link
Member

kvaps commented Jul 26, 2024

Hey there, I was solving this problem for Cozystack, as we were needed to redirect traffic from infra-ingress-controller to user clusters. So, this rule works with no troubles:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    nginx.ingress.kubernetes.io/backend-protocol: AUTO_HTTP
    nginx.ingress.kubernetes.io/configuration-snippet: |
      if ($scheme = http) {
        set $proxy_upstream_name "mynamespace-myservice-80";
        set $proxy_host $proxy_upstream_name;
        set $service_port 80;
      }
    nginx.ingress.kubernetes.io/ssl-passthrough: "true"
    nginx.ingress.kubernetes.io/ssl-redirect: "false"
  labels:
    app.kubernetes.io/managed-by: Helm
  name: myservice
  namespace: mynamespace
spec:
  ingressClassName: mynamespace
  rules:
  - host: example.org
    http:
      paths:
      - backend:
          service:
            name: myservice
            port:
              number: 443
        path: /
        pathType: ImplementationSpecific
      - backend:
          service:
            name: myservice
            port:
              number: 80
        path: /
        pathType: ImplementationSpecific

@longwuyuan
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-kind Indicates a PR lacks a `kind/foo` label and requires one. needs-priority needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one.
Projects
Development

No branches or pull requests

4 participants