Inverbis
By:
Inverbis

Newly added domain shows an old one

October 21, 2016 116 views
Apache DNS Ubuntu

I am on Ubuntu 14.04 with Apache and have several virtual hosts on this droplet. All of them work fine, apart from the one I added yesterday which keeps loading the files from another existing site. The domain itself is not redirected, so I suspect there is either some sort of cache involved or (which is more likely) there is something wrong with the listener setup. It seems that the server just picks the first folder that comes after the 000-default in the alphabetic order and serves it when requests come for the new domain.

So to summarize it plain and simple, the situation can be described thus:

There are domains/sites A, B and C on the same droplet/IP. Having added domain D in the same manner as the other three, when I access http://(www).D.tld, the content I see belongs to site A.

I tried to remove it and then add again to the DigitalOcean DNS Panel, but nothing changed. Rewrote the virtual host directives several times, checked it in 4 browsers, cleared cache and still nothing. Any suggestions?

2 Answers

When you open that domain in browser (or ping it) and you get to your server, that means it points correctly and there are no problems with DNS settings (so removing and adding from DNS panel will not help).

Go though a simple make sure list:

  1. Make sure vhost file is written correctly.
  2. Make sure you enabled site using a2ensite command.
  3. Make sure you restarted apache after settings are done:
  • sudo systemctl restart apache2

Maybe for debugging purpose you can try disabling 000-default If enabled, restart apache and check again.

Also you can clear out browser cache or use another one.

If you want to learn more about it, you can look at How to set up virtual hosts for Apache on Ubuntu 16.04.

The Apache web server is the most popular way to serve web content on the internet. Apache has the ability to serve multiple domains from a single server by using a mechanism called "virtual hosts". If a virtual host is configured correctly for each domain, the web server can correctly route traffic to the appropriate files based on the domain name requested. In this guide, we'll demonstrate how to configure Apache virtual hosts on an Ubuntu 16.04 server.

Good point about the DNS, thanks. As for all the rest, I tried it a few times before posting, but all in vain. Anyway, it seems that it requires some deep digging into the server settings which I don't have time for at the moment. In the meanwhile I've enabled this site on another droplet in the very same manner, and all works fine. Go figure

Have another answer? Share your knowledge.