<p>I want to test my (Helm packaged) Kubernetes application locally using minikube, with a Kubernetes ingress to proxy HTTP to the HTTP services my application provides. But this is not working because the ingress (or ingress controller) is insisting that connections are HTTPS, despite me not requesting TLS. How do I ensure the ingress allows HTTP?</p>

<p><code>kubectl get --output=yaml ingress</code> shows that there is an ingress resource, for HTTP, without TLS:</p>

<pre><code>apiVersion: v1
items:
- apiVersion: extensions/v1beta1
  kind: Ingress
  metadata:
    creationTimestamp: "2019-10-06T10:54:38Z"
    generation: 1
    labels:
      app.kubernetes.io/instance: quarreling-shrimp
      app.kubernetes.io/managed-by: Tiller
      app.kubernetes.io/name: mc
      app.kubernetes.io/version: 2.3.1-SNAPSHOT
      helm.sh/chart: mc-2.3.1
    name: quarreling-shrimp-mc
    namespace: default
    resourceVersion: "126597"
    selfLink: /apis/extensions/v1beta1/namespaces/default/ingresses/quarreling-shrimp-mc
    uid: 296f8d69-8f40-49c5-b352-acbc6ec1cc19
  spec:
    rules:
    - http:
        paths:
        - backend:
            serviceName: quarreling-shrimp-mc-be-svc
            servicePort: 8080
          path: /api
        - backend:
            serviceName: quarreling-shrimp-mc-fe
            servicePort: 80
          path: /
  status:
    loadBalancer:
      ingress:
      - ip: 192.168.122.66
kind: List
metadata:
  resourceVersion: ""
  selfLink: ""
</code></pre>

<p>But when I try to access the application using HTTP, the response tries to redirect to use HTTPS. This is the output of <code>curl -i 192.168.122.66</code>:</p>

<pre><code>HTTP/1.1 308 Permanent Redirect
Server: openresty/1.15.8.1
Date: Sun, 06 Oct 2019 11:22:40 GMT
Content-Type: text/html
Content-Length: 177
Connection: keep-alive
Location: https://192.168.122.66/

&lt;html&gt;
&lt;head&gt;&lt;title&gt;308 Permanent Redirect&lt;/title&gt;&lt;/head&gt;
&lt;body&gt;
&lt;center&gt;&lt;h1&gt;308 Permanent Redirect&lt;/h1&gt;&lt;/center&gt;
&lt;hr&gt;&lt;center&gt;openresty/1.15.8.1&lt;/center&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

Raedwald
<p>minikube uses an <em><a href="https://kubernetes.github.io/ingress-nginx/" rel="nofollow noreferrer">Nginx Ingress controller</a></em>. That controller <a href="https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/annotations/#server-side-https-enforcement-through-redirect" rel="nofollow noreferrer">does a permanent redirect (HTTP status code 308) from initial HTTP to HTTPS</a>:</p>

<blockquote>
  <p>By default the controller redirects (308) to HTTPS if TLS is enabled for that ingress</p>
</blockquote>

<p>But, as you point out, the documentation suggests it should not do a redirect in your case because you have not enabled TLS.</p>

<p>I've observed that once I add <code>host:</code> field to the particular Ingress resource without TLS enabled, the resulting <code>curl</code> command returns <code>HTTP/1.1 200</code> with no redirect action:</p>

<pre><code>  rules:
  - host: example.com
    http:
      paths:
      - backend:
          serviceName: some-svc
          servicePort: 80
        path: /
</code></pre>

<p><code>$ curl -v http://$(kubectl get svc -l component=controller -o jsonpath='{.items[0].status.loadBalancer.ingress[0].ip}') -H 'Host: example.com'</code></p>

<pre><code>&gt; GET / HTTP/1.1
&gt; Host: example.com
&gt; User-Agent: curl/7.47.0
&gt; Accept: */*
&gt; 
&lt; HTTP/1.1 200
</code></pre>

<p>But an HTTP GET without a matching host causes a redirect:</p>

<p><code>$ curl -v http://$(kubectl get svc -l component=controller -o jsonpath='{.items[0].status.loadBalancer.ingress[0].ip}')</code></p>

<pre><code>&gt; GET / HTTP/1.1
&gt; Host: XX.XX.XX.XX
&gt; User-Agent: curl/7.47.0
&gt; Accept: */*
&gt; 
&lt; HTTP/1.1 308 Permanent Redirect
</code></pre>

<p>Therefore, I suppose that although the <code>host:</code> field is optional, if you don't specify it in the target <code>Ingress</code> resource, the Ingress controller will not properly recognize TLS related settings.</p>
