<p>I want to achieve TLS mutual auth between my different services running in a kubernetes cluster and I have found that Istio is a good solution to achieve this without making any changes in code.</p>
<p>I am trying to use Istio sidecar injection to do TLS mutual auth between services running inside the cluster.</p>
<ul>
<li>Outside traffic enters the mesh through nginx ingress controller. We want to keep using it instead of the Istio ingress controller(we want to make as little changes as possible).</li>
<li>The services are able to communicate with each other properly when the Istio Sidecar injection is disabled. But as soon as I enable the sidecar in the application's namespace, the app is not longer able to serve requests(I am guessing the incoming requests are dropped by the envoy sidecar proxy).</li>
</ul>
<p><a href="https://i.stack.imgur.com/mNC7Q.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mNC7Q.jpg" alt="My architecture looks like this" /></a></p>
<p>What I want to do:</p>
<ul>
<li>Enable istio sidecar proxy injection on namespace-2(nginx ingress controller, service 1 and service 2) so that all services communicate with each other through TLS mutual auth.</li>
</ul>
<p>What I don't want to do:</p>
<ul>
<li>Enable istio sidecar proxy injection on the nginx ingress controller(I don't want to make any changes in it as it is serving as frontend for multiple other workloads).</li>
</ul>
<p>I have been trying to make it work since a couple of weeks with no luck. Any help from the community will be greatly appreciated.</p>

dishant makwana
<blockquote>
<p>my goal is to atleast enable TLS mutual auth between service-1 and service-2</p>
</blockquote>
<p>AFAIK if you have enabled injection in namespace-2 then services here already have mTLS enabled. It's enabled by default since istio 1.5 version. There are related <a href="https://istio.io/latest/news/releases/1.5.x/announcing-1.5/upgrade-notes/#automatic-mutual-tls" rel="nofollow noreferrer">docs</a> about this.</p>
<blockquote>
<p>Automatic mutual TLS is now enabled by default. Traffic between sidecars is automatically configured as mutual TLS. You can disable this explicitly if you worry about the encryption overhead by adding the option -- set values.global.mtls.auto=false during install. For more details, refer to <a href="https://istio.io/latest/docs/tasks/security/authentication/authn-policy/#auto-mutual-tls" rel="nofollow noreferrer">automatic mutual TLS</a>.</p>
</blockquote>
<p>Take a look here for more information about how mtls between services works.</p>
<h2>Mutual TLS in Istio</h2>
<blockquote>
<p>Istio offers mutual TLS as a solution for service-to-service authentication.</p>
<p>Istio uses the sidecar pattern, meaning that each application container has a sidecar Envoy proxy container running beside it in the same pod.</p>
<ul>
<li><p>When a service receives or sends network traffic, the traffic always
goes through the Envoy proxies first.</p>
</li>
<li><p>When mTLS is enabled between two services, the client side and server side Envoy proxies verify each other’s identities before sending requests.</p>
</li>
<li><p>If the verification is successful, then the client-side proxy encrypts the traffic, and sends it to the server-side proxy.</p>
</li>
<li><p>The server-side proxy decrypts the traffic and forwards it locally to the actual destination service.</p>
</li>
</ul>
</blockquote>
<p><a href="https://i.stack.imgur.com/7LXQ3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7LXQ3.png" alt="enter image description here" /></a></p>
<h2>NGINX</h2>
<blockquote>
<p>But the problem is, the traffic from outside the mesh is getting terminated at the ingress resource. The nginx reverse proxy in namespace-2 does not see the incoming calls.</p>
</blockquote>
<p>I see there is similar issue on <a href="https://github.com/istio/istio/issues/24668" rel="nofollow noreferrer">github</a> about that, worth to try with this.</p>
<p><a href="https://github.com/istio/istio/issues/14450#issuecomment-498771781" rel="nofollow noreferrer">Answer</a> provided by @stono.</p>
<blockquote>
<p>Hey,
This is not an istio issue, getting nginx to work with istio is a little bit difficult. The issue is because fundamentally nginx is making an outbound request to an ip that is has resolved from your hostname foo-bar. This won't work as envoy doesn't know what cluster ip belongs to, so it fails.</p>
<p>I'd suggest using the ingress-nginx kubernetes project and in turn using the following value in your Ingress configuration:</p>
<p>annotations:
nginx.ingress.kubernetes.io/service-upstream: &quot;true&quot;
What this does is ensure that nginx doesn't resolve the upstream address to an ip, and maintains the correct Host header which the sidecar uses in order to route to your destination.</p>
<p>I recommend using this project because I use it, with Istio, with a 240 odd service deployment.</p>
<p>If you're not using ingress-nginx, I think you can set proxy_ssl_server_name on; or another thing you could try is forcefully setting the Host header on the outbound request to the internal fqdn of the service so:</p>
<p>proxy_set_header Host foo-bar;
Hope this helps but as I say, it's an nginx configuration rather than an istio problem.</p>
</blockquote>
