No se puede redirigir HTTPS a HTTP a través de NGINX

No se puede redirigir HTTPS a HTTP a través de NGINX

Me está costando mucho realizar una redirección de HTTPS a HTTP. Esto me está dando dolor de cabeza estos últimos días porque no puedo entenderlo :|

situación

Tengo un sitio web y un servidor VPS. El sitio web está alojado en un alojamiento web independiente. En el servidor VPS, tengo una API a la que solo se puede acceder a través de HTTP. Por ejemplo, una llamada a la API curl puede verse asícurl http://xxx.xxx.xx.xx:4000/foo/bar

El VPS tiene NGINX instalado con la siguiente configuración de NGINX:

server {
    listen <website-domain-ip>:443;
    server_name localhost <website-domain> www.<website-domain>;
    ssl_certificate     /root/certificates/<website-domain>/certificate.crt;
    ssl_certificate_key /root/certificates/<website-domain>/private.key;

    location ~ / {
        proxy_pass http://127.0.0.1:4000;
    }
 }

# server {
#    listen 80;
#    server_name <website-domain> www.<website-domain>;
#    return 301 http://$http_host$request_uri;
# }

Sin embargo, cuando pruebo la API, aparece Failed to load resource: net::ERR_CONNECTION_REFUSED el error completo.

GET https://xxx.xxx.xx.xxx:4000/foo/bar net::ERR_CONNECTION_REFUSED

¿Qué has probado?

He probado varias configuraciones principalmente para cambiar listensolo 443o agregar ssl. Creo que el problema está aquí (probablemente habrá más problemas, pero creo que el primer problema está aquí). Access.log y error.log están vacíos, lo que debería significar que no hay conexión alguna y que la listenpropiedad no está configurada correctamente.

Tengo control sobre los certificados SSL y tengo el certificado, ca_bundle y la clave privada.

¿Quién me puede ayudar?

ACTUALIZAR

salida completa de curl -ILhttps://ejemplo.com/foo/bar curl: (35) error:0A00010B:SSL routines::wrong version number

En el VPS lsof -ise obtienen los siguientes procesos en ejecución

systemd-n   690 systemd-network   15u  IPv4 853475      0t0  UDP ip185-132-47-xxx.pbiaas.com:bootpc 
systemd-r   692 systemd-resolve   13u  IPv4  24956      0t0  UDP localhost:domain 
systemd-r   692 systemd-resolve   14u  IPv4  24957      0t0  TCP localhost:domain (LISTEN)
sshd        744            root    3u  IPv4  24330      0t0  TCP *:ssh (LISTEN)
sshd        744            root    4u  IPv6  24332      0t0  TCP *:ssh (LISTEN)
postgres    782        postgres    5u  IPv6  31871      0t0  TCP localhost:postgresql (LISTEN)
postgres    782        postgres    6u  IPv4  31872      0t0  TCP localhost:postgresql (LISTEN)
postgres    782        postgres    8u  IPv6  31877      0t0  UDP localhost:60421->localhost:60421 
postgres    788        postgres    8u  IPv6  31877      0t0  UDP localhost:60421->localhost:60421 
postgres    789        postgres    8u  IPv6  31877      0t0  UDP localhost:60421->localhost:60421 
postgres    790        postgres    8u  IPv6  31877      0t0  UDP localhost:60421->localhost:60421 
postgres    791        postgres    8u  IPv6  31877      0t0  UDP localhost:60421->localhost:60421 
postgres    792        postgres    8u  IPv6  31877      0t0  UDP localhost:60421->localhost:60421 
postgres    793        postgres    8u  IPv6  31877      0t0  UDP localhost:60421->localhost:60421 
nginx     35874            root    6u  IPv4 647926      0t0  TCP *:https (LISTEN)
nginx     35874            root    7u  IPv4 647927      0t0  TCP *:http (LISTEN)
nginx     35875        www-data    6u  IPv4 647926      0t0  TCP *:https (LISTEN)
nginx     35875        www-data    7u  IPv4 647927      0t0  TCP *:http (LISTEN)
nginx     35876        www-data    6u  IPv4 647926      0t0  TCP *:https (LISTEN)
nginx     35876        www-data    7u  IPv4 647927      0t0  TCP *:http (LISTEN)
nginx     35877        www-data    6u  IPv4 647926      0t0  TCP *:https (LISTEN)
nginx     35877        www-data    7u  IPv4 647927      0t0  TCP *:http (LISTEN)
nginx     35878        www-data    6u  IPv4 647926      0t0  TCP *:https (LISTEN)
nginx     35878        www-data    7u  IPv4 647927      0t0  TCP *:http (LISTEN)
nginx     35879        www-data    6u  IPv4 647926      0t0  TCP *:https (LISTEN)
nginx     35879        www-data    7u  IPv4 647927      0t0  TCP *:http (LISTEN)
nginx     35880        www-data    6u  IPv4 647926      0t0  TCP *:https (LISTEN)
nginx     35880        www-data    7u  IPv4 647927      0t0  TCP *:http (LISTEN)
sshd      47034            root    4u  IPv4 854019      0t0  TCP ip185-132-47-xxx.pbiaas.com:ssh->148-216-099-087.dynamic.<internet-provider>.<country-code>:55102 (ESTABLISHED)
sshd      47257            root    4u  IPv4 853604      0t0  TCP ip185-132-47-xxx.pbiaas.com:ssh->119.96.159.237:54986 (ESTABLISHED)

información relacionada