<p>I have a nginx reverse proxy deployed. I have few services</p>
<ol>
<li>Service A : https service with its own certificate running on port 8080.</li>
<li>Service B: https service with its own certificate running on port 8080.</li>
</ol>
<p>We have only 1 entry point to the application via nginx and through IP address and not dns names.
We want to do the path based routing. If /servicea is requested we need to forward the request to Service A and certificates need to be of service A. Similarly for Service B.</p>
<p>Explored the SNI based solution but it works based on host name. How can we achieve above configuration in nginx ?</p>
<pre><code>server {
        listen 80 default_server;
        listen [::]:80 default_server ipv6only=on;

        listen 443 ssl;

        root /usr/share/nginx/html;
        index index.html;

        server_name localhost;
        ssl_certificate /etc/nginx/ssl/tls.crt;
        ssl_certificate_key /etc/nginx/ssl/tls.key;

        location / {
                try_files $uri $uri/ =404;
        }
        location /servicea/ {
            proxy_pass https://servicea:8080/;

        }

}
</code></pre>

Tech_Lover
<p>TL;DR: what you want is impossible.</p>
<p>TLS passthrough means that nginx is not terminating the TLS connection but just passing through the original data. This way the client does client-to-server TLS with the final server instead of client-to-nginx + nginx-to-server.</p>
<p>But, in case of TLS passthrough the nginx cannot see the HTTP request inside the TLS connection, since it is client-to-server encrypted. And since the path is only inside this HTTP request, nginx cannot do any path based routing.</p>
