Https redirect on the same port

Hello everyone,

Im exposing the dashboard using a NodePort service while deploying with kubernetes-crd.
The dashboard is accessible under [https://traefik-labs.thinkpad.tld:32443/dashboard/#/]

While trying to setup a to redirect from http to https using this middleware:

apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
  name: traefik-https-redirect
  namespace: traefik
spec:
  redirectScheme:
    scheme: https

The redirect lose the 32443 port and the dashboard is no longer accessible.

I have tried also with a redirectregex middleware:

apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
  name: traefik-https-redirect
  namespace: traefik
spec:
  redirectRegex:
    regex: ^http://(.*)
    replacement: https://${1}
    permanent: true

But it simply doesnt work.
Is there anyway to achieve this.

Thank you in advance.

1 Like

You can also specify the port:

I dont need to redirect on a specific port. What if I expose the service on another port.

This is why you need the port. If not I'm not sure what you are asking in this question.

Already tried setting the port:

apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
  name: traefik-https-redirect
  namespace: traefik
spec:
  redirectScheme:
    scheme: https
    port: "32443"

Well...

I think there is more not right with the config, you are not even getting a redirect, let alone one with a port.

Some more of your configuration might be required to diagnose. And I am not familiar with the Kubernetes, so I'll leave that to others to comment on.