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?
example.comactually pointing to the correct IP-address 192.168.0.213 ? – diya Jan 12 '23 at 10:07webserver IN A 192.168.0.213in the forward zone file. And213 IN PTR webserver.example.com.for the reverse zone. – Ilya Shmadchenko Jan 12 '23 at 11:03curl -v curl http://example.comand for additional understanding and debugging https://serverfault.com/q/725262/984089 and https://serverfault.com/a/1109720/984089 – diya Jan 12 '23 at 12:35example.compointing to your webserver? If so, that's obviously why it doesn't work. – vidarlo Jan 12 '23 at 12:50example.com. IN A 192.168.0.213to theforwardzone. Nowcurlis working fine, I can see my site. Thank you! Should I add the same record to thereversezone? Anyway, I'm going to check thewebserver's status tomorrow. – Ilya Shmadchenko Jan 12 '23 at 14:20