4

There is a HTTPS server on one port (5006). I'd like to make it available on 35001 and serve other things on the same 35001 too (by adding locations like /app, /auth, /admin, etc.).

Server is auth-server.org.local. Trying just to add a port:

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

Output:

$ curl -k -X GET https://auth-server.org.local:5006
<h1>My auth server</h1>

$ curl -k -X GET https://auth-server.org.local:35001
curl: (35) gnutls_handshake() failed: An unexpected TLS packet was received.

Why 35001 doesn't work? What am I missing? I've used this guide: https://www.nginx.com/resources/admin-guide/nginx-https-upstreams/

6

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.