1

Using k8s ingress, is it possible using the same domain send incoming http traffic to a port and https traffic to other port?

I have not find anything in the ingress sepecification to do it or annotations in nginx-ingress-controller

Jxadro
  • 1,497
  • 2
  • 16
  • 36

1 Answers1

0

You will need two objects i.e, service and ingress for this. You need to configure ingress similar to below:

spec:
  rules:
  - host: abc.com
    http:
      paths:
      - backend:
          serviceName: myservice
          servicePort: 80
        path: /uiaccesscontrol
      - backend:
          serviceName: myservice
          servicePort: 443
        path: /uiaccesscontrol

and service will have configurations similar as given below:

spec:
  ports:
    - name: http
      port: 80
      targetPort: 80
    - name: https
      port: 443
      targetPort: 443

Now, https traffic will be routed to secure port 443 and http to 80.

Prateek Jain
  • 2,738
  • 4
  • 28
  • 42
  • more details https://stackoverflow.com/questions/54459015/how-to-configure-ingress-to-direct-traffic-to-an-https-backend-using-https/54459898 – Mark Apr 23 '19 at 14:26
  • 1
    The ingress config above for a 2nd backend with servicePort 443 does not work for me. The config works (also for port 443) after removing the 2nd backend. – jaredboone Jul 18 '19 at 06:48
  • the most obvious solution, but it does not work! ingress converts http/https traffic to http and then send it to some of ports – Demetry Pascal Jul 26 '23 at 14:34