0

I've a JS app that is running on http://localhost:1337. Behind there's a Nginx reverse proxy with the following config:

/etc/nginx/conf.d/upstream.conf

upstream test {
    server 127.0.0.1:1337;
}

/etc/nginx/sites-enabled/test.conf

server {
    # Listen HTTP
    listen 80;
    server_name test.example.com;

    # Redirect HTTP to HTTPS
    return 301 https://$host$request_uri;
}

server {
    # Listen HTTPS
    listen 443 ssl;
    server_name test.example.com;

    # SSL config
    include snippets/self-signed.conf;
    include snippets/ssl-params.conf;

    # Proxy Config
    location / {
        proxy_pass http://test;
        proxy_http_version 1.1;
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Host $http_host;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
        proxy_pass_request_headers on;
    }
}

I can reach the app from outside, so the service is correctly running, but I need to connect to https://test.example.com from inside the same machine where it runs. If I try:

curl https://test.example.com -v

I get "Failed to connect to test.example.com port 443 after 16ms: Connection refused"

Ufw is in inactive status. I've checked /etc/hosts and I've no entry that can cause problems. What else can I check? Many thanks in advance.

Jumpa
  • 111
  • 1
  • 6
  • upstream should have only the ip and in the proxy part should been the port, sometimes it solves it – djdomi Jan 08 '23 at 19:28

0 Answers0