0

I have an nginx reverse proxy setup to point to my nodejs app. When I enter the server IP in the search bar, the website pulls up as expected. When I enter the domain name I get an ERR_CONNECTION_REFUSED error.

I have the following sites-available file for my site:

server {
    listen   80 default_server;
    listen [::]:80;

    server_name mywebsite.com www.mywebsite.com <server_ip>;

    location / {
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Host $host;
            proxy_set_header X-NginX-Proxy true;
            proxy_pass http://0.0.0.0:3000/;
            #proxy_redirect http://127.0.0.1:3000/ https://$server_name/;
    }
}

I've also commented out everything in the default file to avoid conflict.

My ports should be open per ufw:

$ sudo ufw status
Status: active

To                         Action      From
--                         ------      ----
22/tcp                     ALLOW       Anywhere
Nginx Full                 ALLOW       Anywhere
443                        ALLOW       Anywhere
22                         ALLOW       Anywhere
22/tcp (v6)                ALLOW       Anywhere (v6)
Nginx Full (v6)            ALLOW       Anywhere (v6)
443 (v6)                   ALLOW       Anywhere (v6)
22 (v6)                    ALLOW       Anywhere (v6)

When I do a ping on my domain name, it returns the correct IP address.

This is the output of netstat -tlnp

sudo netstat -tnlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:3000            0.0.0.0:*               LISTEN      21671/PM2 v5.3.0: G
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      18646/sshd: /usr/sb
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      26697/nginx: master
tcp        0      0 127.0.0.53:53           0.0.0.0:*               LISTEN      18657/systemd-resol
tcp6       0      0 :::22                   :::*                    LISTEN      18646/sshd: /usr/sb
tcp6       0      0 :::80                   :::*                    LISTEN      26697/nginx: master
xv47
  • 101
  • What browser(s) on what platform(s)? Browsers don't need to, and fairly often don't, use the same name resolution as simpler programs like ping. Can you get a network trace with wireshark or tcpdump or similar to see _exactly_ what connection is being attempted and if it is correct? Or try curl -- that does 'plain' network connection (as long as you don't have a client-side/forward proxy set). – dave_thompson_085 Jun 08 '23 at 02:26
  • use 127.0.0.1 instead of 0.0.0.0 for the revese proxy, never seen such a config. Where is the Server hosted? how do you try to access? – djdomi Jun 13 '23 at 04:43

1 Answers1

0

When I enter the server IP in the search bar, the website pulls up as expected. When I enter the domain name I get an ERR_CONNECTION_REFUSED error.

Then the FIRST thing to check is what the domain name resolves as on the client. Try pinnging the domain name.

(It also proves that a lot of other things are not the cause, including the firewall)

symcbean
  • 21,009
  • 1
  • 31
  • 52