I am quite a noob on Ubuntu but I had to install it on a VPS to display two different websites as sub-domains. One of them is a Drupal 8 website, the other one is a Static html website (index.html)
I got both websites on /var/www and I think I configured everything correctly on apache2 because I added the two subdomains to hosts
file to access locally and do some tests and they work fine.
When I type old.myaddress.com
or new.myaddress.com
both of them load locally. However, if I try to access through internet or from another computer, it will only load the Drupal one, always. Why?
Worth to mention that I got a Domain and configured both old.myaddress.com
and new.myaddress.com
subdomains to redirect to the same IP (my VPS server IP). As far as I understand, apache should send the user to the different sites?
These are my .conf files inside etc/apache2/sites-available
:
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName www.myaddress.com
ServerAlias old.myaddress.com
DocumentRoot /var/www/oldwebsite/myaddress.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName www.myaddress.com
ServerAlias new.myaddress.com
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
To clarify, I'm asking where the missing configuration is. If loading the websites locally works, it may still be apache? It's my DNS? my ISP? Drupal configuration? I'm quite lost.
I'm assuming your DNS domain is correctly configured and
new.myaddress.com
andold.myaddress.com
correctly resolve to your server IP. You can check that on another machine with:It's odd that your configuration works locally and not remotely, if these names resolves to the same IP. Is a
ping
to each address ends up to the same IP address thannslookup
reports?Another thing, the
ServerName
should't have the same value for multiple VirtualHost. You can use anyServerAlias
you want as long as the same value is used only once. I'd remove thewww.myaddress.com
from the old website VirtualHost configuration.Apparently I had to set the correct IPv4 and IPv6 to the record A and record AAAA of the DNSs of my sub-domains.
For DNS providers like 1and1 (Ionos), when you set up a domain or a sub-domain it assumes it's hosted at their locations, and in order to bind it to an external hosting you need to manually edit the records A and AAAA to point to your ip server.