Skip to content
This repository was archived by the owner on Mar 24, 2026. It is now read-only.
This repository was archived by the owner on Mar 24, 2026. It is now read-only.

Same Path, multiple ports #11334

Closed
Closed

Description

@Leonardo-Ferreira

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...

Activity

  1. k8s-ci-robot commented on Apr 30, 2024

    @k8s-ci-robot
    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.

    Details

    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.

  2. added
    needs-triageIndicates an issue or PR lacks a `triage/foo` label and requires one.
    needs-kindIndicates a PR lacks a `kind/foo` label and requires one.
    on Apr 30, 2024
  3. longwuyuan commented on Apr 30, 2024

    @longwuyuan
    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

  4. k8s-ci-robot commented on Apr 30, 2024

    @k8s-ci-robot
    Contributor

    @longwuyuan: Closing this issue.

    Details

    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.

  5. kvaps commented on Jul 26, 2024

    @kvaps
    Member

    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
  6. longwuyuan commented on Jul 26, 2024

    @longwuyuan
    Contributor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-kindIndicates a PR lacks a `kind/foo` label and requires one.needs-priorityneeds-triageIndicates an issue or PR lacks a `triage/foo` label and requires one.

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions