Trying to proxy HTTPS, but getting: An unexpected TLS packet was received

Solution 1:

Your virtual server is a HTTP server, therefore it doesn't work with https connection attempts.

In order to make it HTTPS, you need to have this configuration:

server {
    listen 35001 ssl;
    server_name example.com;

    ssl_certificate /path/to/ssl/certificate;
    ssl_certificate_key /path/to/ssl/certificate;

    location / {
        proxy_pass https://auth-server.local:5006;
    }
}

Alternatively you can set up an nginx stream proxy, which simply passes the TCP stream to backend, so that nginx does not perform SSL termination:

stream {
    server {
        listen 35001;
        proxy_pass auth-server.local:5006;
    }
}

This has to be outside the http context.