0

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.

BTW: Another curiosity: on my Domainhoster I added a subdomain "subdomain2.maindomain" (which I didn't need todo for the other "subdomain1.maindomain"). In the A record I added the server IP_ADDRESS. Now when I head to subdomain2.maindomain nginx redirects to "subdomain2.maindomain/index.php" this loads nextcloud which gives me of course an trsuted_domains error. Why is nginx redirecting to nextcloud?

What can I do next? Thanks for any help!

1
  • 2
    DNS_PROBE_FINISHED_NXDOMAIN is a DNS error. It has nothing to do with nginx. What are your DNS records? Commented Sep 10, 2022 at 17:24

1 Answer 1

0

Seems, like it really was I problem with the DNS Servers. After about 24h the subdomain worked just fine. Should have waited a bit longer...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.