ingress-nginx permanent redirect 301 not working

4/5/2018

UPDATE: This problem solved itself. I can't tell why. I just tried again the next day and it worked with the config below.

I'm using the "ingress-nginx" ingress controller (v. 0.12.0). It works fine except for permanent redirects.

In order to redirect foo.example.com to https://google.com I applied the following ingress config:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    # nginx.ingress.kubernetes.io/ssl-redirect: "false"
    nginx.ingress.kubernetes.io/permanent-redirect: "https://google.com"
  name: redirect-test
  namespace: default
spec:
  rules:
  - host: foo.example.com
    http:
      paths:
      - backend:
          serviceName: default-backend 
          servicePort: 80
  tls:
  - hosts:
    - foo.example.com
    secretName: domains-tls

But if I enter foo.example.com in the browser I get this:

We're sorry, but we were unable to process the redirection request for the site you are attempting to access.

If you feel that you are receiving this message in error, please check the URL and try your request again.

UT

(RF)

Does anyone know what goes wrong here?

-- Rotareti
kubernetes
kubernetes-ingress
nginx

1 Answer

10/22/2018

I had this same issue,

I fixed it by upgrading the nginx-ingress chart from nginx-ingress-0.8.13 to nginx-ingress-0.22.0

I assume the permanent redirect annotation nginx.ingress.kubernetes.io/permanent-redirect did not existed in 0.8.13.

So either helm upgrade your chart or upgrade your nginx-ingress directly.

-- santiaago
Source: StackOverflow