DNS_PROBE_FINISHED_NXDOMAIN when serving multiple subdomains with nginx

Viewed 18

On our research project, we have an Ubuntu 20.04 LTS virtual machine running, which should serve via nginx multiple project related websites/apps on different subdomains.

The setup is supposed to be as following: maindomain --> redirecting to our project info site hosted by our university subdomain1.maindomain --> nextcloud for project management stuff served via nginx subdomain2.maindomain --> serving app1 via nginx proxy and gunicorn (for django) subdomain3.maindomain --> serving app2 via nginx proxy and express.js

What I did:

  • Added the IP address of the server to the A record of our German domain hoster Strato.
  • https://maindomain: configured nginx to redirect to university site
server {
        listen 80;
        listen [::]:80;

        listen 443      ssl http2;
        listen [::]:443 ssl http2;
        root /var/www/html;

        server_name maindomain;
        return 301 https://university-site;

        ssl_certificate /etc/ssl/wildcard.crt;
        ssl_certificate_key /etc/ssl/wildcard.key;
        ssl_trusted_certificate /etc/ssl/wildcard.crt;
        ssl_dhparam /etc/ssl/certs/dhparam.pem;
}
  • configured nginx to serve nextcloud stuff in /etc/nginx/sites-available/subdomain1.maindomain
server {
        listen 80;
        #listen [::]:80;
        server_name subdomain1.maindomain;
        return 301 https://$server_name$request_uri;
}

server {
        listen 443      ssl http2;
        listen [::]:443 ssl http2;
        root /var/www/nextcloud;
        index index.html index.php /index.php$request_uri;
        server_name subdomain1.maindomain;

        ssl_certificate /etc/ssl/wildcard.crt;
        ssl_certificate_key /etc/ssl/wildcard.key;
        ssl_trusted_certificate /etc/ssl/wildcard.crt;
        ssl_dhparam /etc/ssl/certs/dhparam.pem;

... lot's of nextcloud related stuff ...
}

up to this point: everything is working fine for some time now

What I tried:

Now it was time to start deploying the next app on subdomain2.maindomain. In my naive thinking I thought just to copy /etc/nginx/sites-available/subdomain1.maindomain to subdomain2.maindomain and change "subdomain1.maindomain" to "subdomain2.maindomain" in the config file (of course: getting rid of all the nextcloud stuff, too).

First I experimented with just serving a static index.html page to see if everything is working:

server {
        listen 80;
        server_name subdomain2.maindomain;
        root /var/www/subdomain2;
        index index.html index.php /index.php$request_uri;
        # return 301 https://$server_name$request_uri;
}
  • added a static index.html into /var/www/subdomain2
  • restarted nginx (feels like a 1000 times actually... :-))

Now when I try to navigate to "http://subdomain2.maindomain" it throws the error: DNS_PROBE_FINISHED_NXDOMAIN

For testing purposes I added our IP address to the configuration /etc/nginx/sites-available/subdomain2.maindomain, resulting in:

server {
        listen 80;
        server_name subdomain2.maindomain IP_ADDRESS;
        root /var/www/subdomain2;
        index index.html index.php /index.php$request_uri;
        # return 301 https://$server_name$request_uri;
}

Now, when I browse to IP_ADDRESS the static index.html page is served just as expected, but browsing to subdomain2.maindomain still fails.

What can I do next?

0 Answers
Related