<p>When I use nginx as ingress controller for my k8s cluster, specifying an ingress rule automatically creates corresponding configurations in the /etc/nginx/conf.d/ files of nginx pod.</p>
<p>So, it configures proxy_pass directive there to relevant upstream/backend service. And it is http.
For this ingress rule for my service:</p>
<pre><code>apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: my-ingress
  # annotations:
  #  nginx.org/redirect-to-https: &quot;false&quot;
  #  #nginx.ingress.kubernetes.io/ssl-passthrough: &quot;true&quot;
spec:
  ingressClassName: nginx 
  tls:
  - hosts:
    - test.myapp.com
    secretName: test-tls-secret
  rules:
  - host: test.myapp.com
    http:
      paths:
      - backend:
          serviceName: myui
          servicePort: 80
      - path: /api/
        backend:
          serviceName: myapp
          servicePort: 88              
</code></pre>
<p>By default, it automatically creates this directive for backend in nginx configuration:</p>
<pre><code> proxy_pass http://default-my-ingress-test.myapp.com-myapp-88;
</code></pre>
<p>But instead, i need it to be https like this:</p>
<pre><code>proxy_pass https://default-my-ingress-test.myapp.com-myapp-88;
</code></pre>
<p>Then only my application will work as that backend accepts https requests only.</p>
<p>Is there any way to modify that proxy_pass directive for a particular backend service for this purpose, using any annotations or something like that via Ingress resource?</p>
<hr />
<p><strong>EDIT:</strong></p>
<p>Is there any annotation like that available?</p>
<p>Or Is there any option that I could handle it with a sidecar container in the same pod with the actual <code>myapp</code> container?</p>

AnjK
<p>I had a similar requirement very recently where the backend pods expected the request on https.</p>
<p>What you'd need is <a href="https://kubernetes.github.io/ingress-nginx/user-guide/tls/#ssl-passthrough" rel="nofollow noreferrer">ssl-passthrough</a> feature of nginx controller. You need to start the nginx ingress controller with flag <code>--enable-ssl-passthrough</code>. This can be passed as a command line argument to the nginx deployment.</p>
<p>Thereafter, the ingress resource needs to be deployed with the following annotations:</p>
<pre><code>kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/backend-protocol: &quot;HTTPS&quot;
nginx.ingress.kubernetes.io/secure-backends: &quot;true&quot;
nginx.ingress.kubernetes.io/ssl-redirect: &quot;true&quot;
nginx.ingress.kubernetes.io/ssl-passthrough: &quot;true&quot;
</code></pre>
<p>to instruct the controller to send TLS connections directly to the backend.</p>
