FULL AI ANALYSIS

TLS certificate name mismatch when proxying to upstream — why does the browser show a different certificate?

Generated Nov 5, 2026, 9:37:41 AM

Analysis summary

When a proxy performs TLS to an upstream HTTPS server it must present the correct SNI name (proxy_ssl_name/proxy_ssl_server_name in NGINX) so the upstream selects the certificate that matches the public hostname. If the proxy uses an IP address or omits SNI, the upstream may return a default cert. Additionally, proxy may be terminating TLS itself and serving its own cert to clients. Diagnosis should confirm which TLS session is failing (client→proxy or proxy→upstream) and whether SNI is set by the proxy.

Possible causes

Proxy not sending SNI to upstream (proxy_ssl_server_name off or proxy connecting by IP)

80%

Proxy terminating TLS and presenting its own certificate that lacks the requested SAN

60%

Upstream default virtual host certificate does not include the expected hostname

50%

Client or middlebox stripping SNI (older clients or transparent TLS interceptors)

10%

Suggested fixes

1

Diagnostic step 1

From the proxy host, test the upstream TLS handshake with SNI: openssl s_client -connect upstream:443 -servername expected.hostname and without SNI: openssl s_client -connect upstream:443 Result meaning: If the certificate returned differs between commands, the upstream selects certs based on SNI. A correct cert with -servername but a default or different cert without it indicates SNI must be sent by the proxy.

2

Diagnostic step 2

Inspect NGINX proxy config for proxy_ssl_server_name on; check proxy_ssl_name if present and whether proxy_pass uses a hostname or IP Result meaning: If proxy_pass uses an IP, NGINX cannot infer the name; enabling proxy_ssl_server_name and setting proxy_ssl_name to the desired hostname will instruct NGINX to send SNI. If proxy_ssl_server_name is off, NGINX won't send SNI and upstream may return a default cert.

3

Diagnostic step 3

Use curl --resolve 'public-host:443:PROXY_IP' -vk https://public-host/ to test client→proxy TLS and openssl s_client to test proxy→upstream separately; review nginx error.log and access.log for proxy_ssl verification messages Result meaning: If client→proxy TLS serves the proxy cert and proxy→upstream returns the wrong cert when checked separately, the issue is upstream name selection. If client sees proxy cert mismatch, adjust proxy TLS cert. Logs may show certificate verification failures if proxy validates upstream certs.

4

Diagnostic step 4

If proxy validates upstream cert, ensure proxy trusts upstream CA: check proxy's trusted certificate store and proxy_ssl_trusted_certificate directive Result meaning: If trust is missing, proxy may fail verification and either abort or accept defaults; configuring the correct trusted CA allows proxy to validate and also to use proxy_ssl_server_name safely.