Невозможно перенаправить HTTPS на HTTP через NGINX

Невозможно перенаправить HTTPS на HTTP через NGINX

У меня очень сложно сделать перенаправление с HTTPS на HTTP. Это доставляет мне головную боль последние несколько дней, потому что я не могу разобраться :|

ситуация

У меня есть веб-сайт и сервер VPS. Веб-сайт размещен на отдельном веб-хостинге. На сервере VPS у меня есть API, доступ к которому возможен только через HTTP. Например, вызов API curl может выглядеть такcurl http://xxx.xxx.xx.xx:4000/foo/bar

На VPS установлен NGINX со следующей конфигурацией 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;
# }

Однако, когда я пробую API, я получаю Failed to load resource: net::ERR_CONNECTION_REFUSED полную ошибку

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

Что вы пробовали?

Я пробовал несколько конфигураций, в основном, чтобы изменить listenна только 443или добавить ssl. Я думаю, что проблема здесь (вероятно, будут и другие проблемы, но первая проблема здесь, я думаю). Access.log и error.log пусты, что должно означать, что вообще нет соединения и свойство listenнастроено неправильно.

У меня есть контроль над сертификатами SSL, а также сертификат, ca_bundle и закрытый ключ.

Кто может мне помочь?

ОБНОВЛЯТЬ

полный вывод curl -ILhttps://example.com/foo/bar curl: (35) error:0A00010B:SSL routines::wrong version number

На VPS lsof -iзапущены следующие процессы

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)

Связанный контент