Reverse Proxy 502 Bad Gateway

Maxim Dounin mdounin at
Fri Mar 3 20:45:31 UTC 2023


On Fri, Mar 03, 2023 at 04:33:25PM +0100, Hans Müller wrote:

>    Hello,
>    I am working in a proxmox environment, setting up a ngnix reverse proxy
>    ( forwarding requests via https to a nginx backend
>    server ( On the backend server shellinabox is
>    installed. Request from the internet are secured via a Letsentcrypt
>    certificate. For the encryption to the backend server I use a
>    self-signed certificate.
>    When I want to open the I get an 502 Bad Gateway
>    error
>    On the reverse proxy are the following configs
>    HttpGateway


>    location / {
>    proxy_set_header Host $host;
>    proxy_set_header X-Real-IP $remote_addr;
>    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
>    proxy_ssl_certificate /etc/selfcerts/stern-example-cert-chain.pem;
>    proxy_ssl_certificate_key /etc/selfcerts/stern-example-key.pem;
>    proxy_ssl_verify off;
>    proxy_pass [1];

Note you are proxying using the "https" protocol.


>    On the backend server there is the following config
>    server {
>    listen;
>    server_name;

But the backend is not configured to use SSL on the socket (or at 
least this is not something visible from the configuration 
provided).  Note no "ssl" parameter on the listen directive.


>    When I try to open the page there is this error in the nginx error log
>    {{{
>    [error] 1103#1103: *1 SSL_do_handshake() failed (SSL:
>    error:0A00010B:SSL routines::wrong version
>    number) while SSL handshaking to upstream, client:,
>    server:, request: "GET /f
>    avicon.ico HTTP/2.0", upstream:
>    "[3]", host:
>    ""
>    }}}
>    Any idea, what I can do here?

The error is somewhat expected: you are trying to connect to 
non-SSL port using SSL, and this is expected to fail.

You should either configure SSL on the backend, or change proxying 
to use the "http" protocol instead.

Maxim Dounin

More information about the nginx mailing list