<p>Using the latest version of microk8s and trying to set up load balancer to headless service running in the cluster, this is what I have:</p>
<pre><code>$ k get all -n ingress
NAME                                          READY   STATUS    RESTARTS        AGE
pod/nginx-ingress-microk8s-controller-9m59x   1/1     Running   21 (134m ago)   118d

NAME                  TYPE           CLUSTER-IP      EXTERNAL-IP    PORT(S)                      AGE
service/svc-metallb   LoadBalancer   10.152.183.27   192.168.1.77   80:30155/TCP,443:31357/TCP   90m

NAME                                               DESIRED   CURRENT   READY   UP-TO-DATE   AVAILABLE   NODE SELECTOR   AGE
daemonset.apps/nginx-ingress-microk8s-controller   1         1         1       1            1           &lt;none&gt;          118d
</code></pre>
<pre><code>$ k get ingress
NAME      CLASS    HOSTS   ADDRESS     PORTS   AGE
ingress   public   *       127.0.0.1   80      111m
</code></pre>
<pre><code>$ k describe ingress
Name:             ingress
Labels:           app=ingress
Namespace:        default
Address:          127.0.0.1
Ingress Class:    public
Default backend:  &lt;default&gt;
Rules:
  Host        Path  Backends
  ----        ----  --------
  *           
              /aspnetcorewebapi(/|$)(.*)   svc-aspnetcorewebapi:443 (10.1.207.217:443,10.1.207.220:443)
Annotations:  kubernetes.io/ingress.class: nginx
              nginx.ingress.kubernetes.io/rewrite-target: /$2
              nginx.ingress.kubernetes.io/ssl-redirect: false
Events:
  Type    Reason  Age                From                      Message
  ----    ------  ----               ----                      -------
  Normal  Sync    7s (x12 over 86m)  nginx-ingress-controller  Scheduled for sync
</code></pre>
<pre><code>$ k get svc
svc-aspnetcorewebapi                         ClusterIP   None             &lt;none&gt;        443/TCP                         16d
</code></pre>
<p><code>ingress.yml</code>:</p>
<pre><code>apiVersion: networking.k8s.io/v1
kind: Ingress 
metadata:
  name: ingress 
  namespace: default 
  annotations:
    nginx.ingress.kubernetes.io/ssl-redirect: &quot;false&quot; 
    nginx.ingress.kubernetes.io/rewrite-target: /$2
  labels: 
    app: ingress 
spec:
  ingressClassName: public
  rules:  
  - host: 
    http:   
      paths:  
      - pathType: Prefix
        path: /aspnetcorewebapi(/|$)(.*)
#        path: /aspnetcorewebapi
        backend:
          service:
            name: svc-aspnetcorewebapi
            port:
              number: 443

</code></pre>
<p><code>svc-metallb.yml</code>:</p>
<pre><code>apiVersion: v1
kind: Service 
metadata:
  name: svc-metallb
  namespace: ingress 
spec:
  selector:
    name: nginx-ingress-microk8s
  type: LoadBalancer
  externalTrafficPolicy: Cluster 
  # loadBalancerIP is optional. MetalLB will automatically allocate an IP 
  # from its pool if not specified. You can also specify one manually.
  # loadBalancerIP: x.y.z.a 
  ports:  
    - name: http
      protocol: TCP
      port: 80
      targetPort: 80
    - name: https
      protocol: TCP
      port: 443
      targetPort: 443
</code></pre>
<p>Ingress controller log:</p>
<pre><code>[nginx-ingress-microk8s-controller-9m59x] 2022/07/03 08:47:50 [error] 20225#20225: *1345350 upstream prematurely closed connection while reading response header from upstream, client: 192.168.1.77, server: _, request: &quot;GET /aspnetcorewebapi HTTP/2.0&quot;, upstream: &quot;http://10.1.207.217:443/&quot;, host: &quot;localhost&quot; 
[nginx-ingress-microk8s-controller-9m59x] 2022/07/03 08:47:50 [error] 20225#20225: *1345350 upstream prematurely closed connection while reading response header from upstream, client: 192.168.1.77, server: _, request: &quot;GET /aspnetcorewebapi HTTP/2.0&quot;, upstream: &quot;http://10.1.207.220:443/&quot;, host: &quot;localhost&quot; 
[nginx-ingress-microk8s-controller-9m59x] 2022/07/03 08:47:50 [error] 20225#20225: *1345350 upstream prematurely closed connection while reading response header from upstream, client: 192.168.1.77, server: _, request: &quot;GET /aspnetcorewebapi HTTP/2.0&quot;, upstream: &quot;http://10.1.207.217:443/&quot;, host: &quot;localhost&quot; 
[nginx-ingress-microk8s-controller-9m59x] 192.168.1.77 - - [03/Jul/2022:08:47:50 +0000] &quot;GET /aspnetcorewebapi HTTP/2.0&quot; 502 150 &quot;-&quot; &quot;curl/7.81.0&quot; 39 0.002 [default-svc-aspnetcorewebapi-443] [] 10.1.207.217:443, 10.1.207.220:443, 10.1.207.217:443 0, 0, 0 0.000, 0.000, 0.000 502, 502, 502 02f391a2e049f1c2e4ab8d9dff31effb
</code></pre>
<p>I get <code>502 Bad Gateway</code> response. Any advice and insight is appreciated.</p>

Kok How Teh
<p><code>nginx.ingress.kubernetes.io/backend-protocol: &quot;HTTPS&quot;</code> does the job!</p>
