0

I’ve started a nginx webserver recently with Ubuntu Server 22.04 as usual. The hypervisor is VMware Workstation 16.2.4. When I open the site http://192.168.0.213 I can see the default nginx page. But if I try to use my domain name example.com page won’t be found… I make attempts on my host and on other virtual machines using curl. The result is the same. And I’m not able to open my site even from webserver! The command nginx -t output is successful.

obfuscateduser@dnsserver:~$ curl http://example.com
curl: (7) Failed to connect to example.com port 80 after 0 ms: Connection refused

obfuscateduser@webserver:~$ curl http://example.com
curl: (7) Failed to connect to example.com port 80 after 1 ms: Connection refused

/etc/nginx/sites-available/example.com

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

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

        server_name example.com www.example.com;

        location / {
                try_files $uri $uri/ =404;
        }
}

/var/www/example.com/html/index.html

<html>
    <head>
        <title>Welcome to EXAMPLE.COM!</title>
    </head>
    <body>
        <h1>Success!  The your_domain server block is working!</h1>
    </body>
</html>

Permissions

obfuscateduser@webserver:~$ ll /var/www/example.com/html/
total 12
drwxr-xr-x 2 obfuscateduser obfuscateduser 4096 Jan 12 12:00 ./
drwxr-xr-x 3 root root 4096 Jan 11 17:19 ../
-rw-rw-r-- 1 obfuscateduser obfuscateduser  172 Jan 12 11:39 index.html

Firewall output

Status: active

To                      Action      From
--                      ------      ----
Nginx HTTP              ALLOW       Anywhere                 
OpenSSH                 ALLOW       Anywhere                 
Nginx HTTP (v6)         ALLOW       Anywhere (v6)            
OpenSSH (v6)            ALLOW       Anywhere (v6)       

Should I shut down the firewall? Or should I add a special entry in DNS zones files? Might I add some other records to the example.com file?

  • Is the DNS record for `example.com` actually pointing to the correct IP-address 192.168.0.213 ? – diya Jan 12 '23 at 10:07
  • No, there's only an entry `webserver IN A 192.168.0.213` in the forward zone file. And `213 IN PTR webserver.example.com.` for the reverse zone. – Ilya Shmadchenko Jan 12 '23 at 11:03
  • Consider running curl with increased verbosity i.e. `curl -v curl http://example.com` and for additional understanding and debugging https://serverfault.com/q/725262/984089 and https://serverfault.com/a/1109720/984089 – diya Jan 12 '23 at 12:35
  • 1
    @IlyaShmadchenko So you don't have a A record from `example.com` pointing to your webserver? If so, that's obviously why it doesn't work. – vidarlo Jan 12 '23 at 12:50
  • @diya, @vidarlo, I've added `example.com. IN A 192.168.0.213` to the `forward` zone. Now `curl` is working fine, I can see my site. Thank you! Should I add the same record to the `reverse` zone? Anyway, I'm going to check the `webserver`'s status tomorrow. – Ilya Shmadchenko Jan 12 '23 at 14:20
  • No need to use reverse zone to access the site! – Pothi Kalimuthu Jan 16 '23 at 06:59

0 Answers0