ingress-nginx http redirect code: "301" too many redirects

12/4/2018

I tried to change configmap for nginx in order to change default permenant redirection code from 308 to 301, but i faced a "too many redirect".

here is my config:

configmap.yaml

apiVersion: v1
data:
    proxy-connect-timeout: "15"
    proxy-read-timeout: "600"
    proxy-send-timeout: "600"
    hsts-include-subdomains: "false"
    body-size: "64m"
    server-name-hash-bucket-size: "256"
    kind: ConfigMap
metadata:
    name: nginx

ingress-website.yaml

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
    name: wordpress
    annotations:
       kubernetes.io/ingress.class: nginx
       kubernetes.io/tls-acme: "true"
       ingress.kubernetes.io/force-ssl-redirect: 'true'
       ingress.kubernetes.io/from-to-www-redirect: "true"
       nginx.ingress.kubernetes.io/permanent-redirect: https://www.example.com
       nginx.ingress.kubernetes.io/permanent-redirect-code: '301'
spec:
    tls:
     - hosts:
        - example.com
        - www.example.com
        - blog.example.com
        secretName: website-tls
    rules:
     - host: example.com
       http:
         paths:
          - path: /
            backend:
              serviceName: domain-website
              servicePort: 8080
     - host: www.example.com
       http:
         paths:
           - path: /
           backend:
             serviceName: example-website
             servicePort: 8080
     - host: blog.example.com
       http:
         paths:
           -
             backend:
               serviceName: wordpress
               servicePort: 80
             path: /

i am wondering to redirect to https using 301 code and not 308

-- Salim Ben Hassine
https
kubernetes-ingress
nginx
nginx-ingress
redirect

0 Answers