<p>I am setting up my first ingress in kubernetes using nginx-ingress. I set up the <code>ingress-nginx</code> load balancer service like so:</p>

<pre><code>{
  "kind": "Service",
  "apiVersion": "v1",
  "metadata": {
    "name": "ingress-nginx",
    "namespace": "...",
    "labels": {
      "k8s-addon": "ingress-nginx.addons.k8s.io"
    },
    "annotations": {     
      "service.beta.kubernetes.io/aws-load-balancer-backend-protocol": "tcp",
      "service.beta.kubernetes.io/aws-load-balancer-proxy-protocol": "*",
      "service.beta.kubernetes.io/aws-load-balancer-ssl-cert": "arn....",
      "service.beta.kubernetes.io/aws-load-balancer-ssl-ports": "443"
    }
  },
  "spec": {
    "ports": [
      {
        "name": "http",
        "protocol": "TCP",
        "port": 80,
        "targetPort": "http",
        "nodePort": 30591
      },
      {
        "name": "https",
        "protocol": "TCP",
        "port": 443,
        "targetPort": "http",
        "nodePort": 32564
      }
    ],
    "selector": {
      "app": "ingress-nginx"
    },
    "clusterIP": "...",
    "type": "LoadBalancer",
    "sessionAffinity": "None",
    "externalTrafficPolicy": "Cluster"
  },
  "status": {
    "loadBalancer": {
      "ingress": [
        {
          "hostname": "blablala.elb.amazonaws.com"
        }
      ]
    }
  }
}
</code></pre>

<p>Notice how the <code>https</code> port has its <code>targetPort</code> property pointing to port 80 (http) in order to terminate ssl at the load balancer.</p>

<p>My ingress looks something like this:</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata: 
  name: something
  namespace: ...
  annotations:
    ingress.kubernetes.io/ingress.class: "nginx"
    ingress.kubernetes.io/force-ssl-redirect: "true"
spec:
  rules:
    - host: www.exapmle.com
      http:
        paths:
         - path: /
           backend:
            serviceName: some-service
            servicePort: 2100
</code></pre>

<p>Now when I navigate to the url I get a <code>Too many redirects error</code>. Something that is confusing me is that when I add the following header "X-Forwarded-Proto: https" I get the expected response (<code>curl https://www.example.com -v -H "X-Forwarded-Proto: https"</code>). </p>

<p>Any ideas how I can resolve the issue?</p>

<p>P.S. this works just fine with <code>ingress.kubernetes.io/force-ssl-redirect: "false"</code> and it doesn't seem that there are any extraneous redirects.</p>

<p>Adding another cause for the <code>Too many redirects error</code>.</p>
<p>While working with <em>ingress-nginx</em> as an ingress controller in front of some k8s services.</p>
<p><strong>One of the services</strong> (ArgoCD in my case) <strong>handled TLS termination by itself and always redirects HTTP requests to HTTPS</strong>. <br></p>
<p><strong>The problem is that the nginx ingress controller also handled TLS termination</strong> and communicates with the backend service with HTTP then the result is that the ArgoCD's server always responding with a redirects to HTTPS which is the cause for the multiple redirects.</p>
<p>Any attempts to pass relevant values to the ingress <strong>annotations below will not help</strong>:</p>
<pre><code>annotations:
  nginx.ingress.kubernetes.io/ssl-redirect: false/true
  nginx.ingress.kubernetes.io/backend-protocol: &quot;HTTP&quot;/&quot;HTTPS&quot;
</code></pre>
<p><strong>The solution was to ensure that the service doesn't handle TLS by passing <code>--insecure</code> flag to the argocd-server deployment</strong>:</p>
<p>spec:</p>
<pre><code>  template:
    spec:
      containers:
      - name: argocd-server
        command:
        - argocd-server
        - --repo-server
        - argocd-repo-server:8081
        - --insecure # &lt;-- Here
</code></pre>
