Score:0

Connection refused inside the same machine

it flag

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.

djdomi avatar
za flag
upstream should have only the ip and in the proxy part should been the port, sometimes it solves it
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.