apiVersion: networking.k8s.io/v1 kind: Ingress metadata: labels: app: website-preview name: website-preview namespace: website annotations: traefik.ingress.kubernetes.io/router.entrypoints: web, websecure traefik.ingress.kubernetes.io/router.middlewares: website-drop-www-redirect-preview@kubernetescrd spec: ingressClassName: traefik rules: - host: preview.goudham.com http: paths: - backend: service: name: website-preview port: number: 3000 path: / pathType: Prefix - host: www.preview.goudham.com http: paths: - backend: service: name: website-preview port: number: 3000 path: / pathType: Prefix tls: - hosts: - preview.goudham.com --- apiVersion: traefik.containo.us/v1alpha1 kind: Middleware metadata: name: drop-www-redirect-preview namespace: website spec: redirectRegex: regex: ^https://www.preview.goudham.com/(.*) replacement: https://preview.goudham.com/${1}