0

I have a strange problem with my Ubuntu Server 20.04 LTS

Brief Background:

I installed nginx and have been having alot of trouble with setting up letsencrypt. Attempting this with a statically served file, it continuously said the connection was refused. I reverted back to the original nginx default configuration, from localhost I see the page content "Welcome to NGINX" in HTML, but from multiple external sources, I keep getting connection refused.

Configuration Default NGINX configuration (copy + pasted directly)

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

        root /var/www/html;
        index index.html index.htm index.nginx-debian.html;

        server_name _;
                try_files $uri $uri/ =404;
                # proxy_pass http://localhost:8080;
                # proxy_http_version 1.1;
                # proxy_set_header Upgrade $http_upgrade;
                # proxy_set_header Connection 'upgrade';
                # proxy_set_header Host $host;
                # proxy_cache_bypass $http_upgrade;
        }
}

Using curl, I attempt to connect to port 80 from a remote site:

curl http://my-domain.com

responding with

curl: (7) Failed to connect to my-domain.com port 80: Connection refused

Other Information:

Active NGINX configuration added to sites-enabled

blms@my-domain:/etc/nginx/sites-enabled$ ls -la
total 8
drwxr-xr-x 2 root root 4096 Sep 28 03:57 .
drwxr-xr-x 8 root root 4096 Sep 28 03:29 ..
lrwxrwxrwx 1 root root   34 Sep 28 03:57 default -> /etc/nginx/sites-available/default

Nginx Service Status: Active (no errors reported)

blms@my-domain:~$ sudo systemctl status nginx
● nginx.service - A high performance web server and a reverse proxy server
     Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
     Active: active (running) since Mon 2020-09-28 03:57:26 UTC; 6min ago
       Docs: man:nginx(8)
    Process: 2901 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
    Process: 2912 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
   Main PID: 2913 (nginx)
      Tasks: 2 (limit: 1074)
     Memory: 2.6M
     CGroup: /system.slice/nginx.service
             ├─2913 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
             └─2914 nginx: worker process

Sep 28 03:57:25 my-domain.com systemd[1]: Starting A high performance web server and a reverse proxy server...
Sep 28 03:57:26 my-domain.com systemd[1]: Started A high performance web server and a reverse proxy server.

Confirmed HTTP Server listening on port 80:

blms@my-domain:~$ sudo ss -tlp | grep http
LISTEN   0        511              0.0.0.0:http                  0.0.0.0:*       users:(("nginx",pid=2914,fd=6),("nginx",pid=2913,fd=6))
LISTEN   0        511                 [::]:http                     [::]:*       users:(("nginx",pid=2914,fd=7),("nginx",pid=2913,fd=7))

iptables allowing all connections

blms@my-domain:~$ sudo iptables -L -v
Chain INPUT (policy ACCEPT 2936 packets, 238K bytes)
 pkts bytes target     prot opt in     out     source               destination

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination

Chain OUTPUT (policy ACCEPT 2567 packets, 393K bytes)
 pkts bytes target     prot opt in     out     source               destination

Frankly, I am quite stumped. I have also restarted to no avail.

Any suggestions?

Update

curl with IP address

curl x.y.z.a:80
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:--  0:00:03 --:--:--     0
curl: (7) Failed to connect to x.y.z.a port 80: Connection refused

curl localhost on server itself

curl localhost
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>
Michael Hampton
  • 237,123
  • 42
  • 477
  • 940
CybeX
  • 273
  • 2
  • 6
  • 17

1 Answers1

2

The cause of the problem was one of my own.

the issue was I had not flushed my NAT table. I did this using iptables -F -t nat. This cleared the problem right up.

I am leaving this answer here in the hopes that it may help someone else.

CybeX
  • 273
  • 2
  • 6
  • 17