0

I have various subdomains set up successfully as virtual hosts on my Digital Ocean Droplet. For some reason though, my latest subdomain is serving a different subdomain, and I'm not sure why. So if you go to selingo.mikeheavers.com it services the contents of exhibitcolumbus.mikeheavers.com. Furthermore, if you just enter my droplet's IP address, it serves exhibitcolumbus.mikeheavers.com - I would expect it to just serve mikeheavers.com. What have I mixed up?

I set both subdomains up through a .conf file and sudo a2ensite [file.com.conf]

This is the contents of selingo.mikeheavers.com.conf:

<VirtualHost *:80>
        <Directory /var/www/html>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>


        ServerAdmin mheavers@gmail.com
        ServerName selingo.mikeheavers.com
        ServerAlias www.selingo.mikeheavers.com
        DocumentRoot /var/www/selingo/public_html


        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
        LogLevel warn rewrite:trace8

        RewriteEngine On
        RewriteCond %{SERVER_NAME} =selingo.mikeheavers.com
        RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent]
</VirtualHost>

and this is exhibitcolumbus.com.conf:

<VirtualHost *:80>
        <Directory /var/www/html>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>

        ServerName exhibitcolumbus.mikeheavers.com
        ServerAlias www.exhibitcolumbus.mikeheavers.com
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/exhibitcolumbus/public_html


        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
        LogLevel warn rewrite:trace8

RewriteEngine on
RewriteCond %{SERVER_NAME} =exhibitcolumbus.mikeheavers.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

I also noticed this in my /etc/hosts file, and I'm not sure where the first entry came from - I don't remember setting it up:

127.0.1.1 extra extra
127.0.0.1 localhost

I'm also using letsencrypt for SSL, so possible that is causing issues? I saw that it created some conf files as well, but they are basically the same as above, with the addition of:

SLCertificateFile /etc/letsencrypt/live/exhibitcolumbus.mikeheavers.com/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/exhibitcolumbus.mikeheavers.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateChainFile /etc/letsencrypt/live/exhibitcolumbus.mikeheavers.com/chain.pem

I also set up A Records for each subdomain on my droplet which point to my IP address (http://107.170.120.88/), which is weirdly also not serving up my primary domain (should be what you see at mikeheavers.com)

I see this when I enter apachectl -S:

AH00112: Warning: DocumentRoot [/var/www/html] does not exist
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
VirtualHost configuration:
*:443                  is a NameVirtualHost
         default server exhibitcolumbus.mikeheavers.com (/etc/apache2/sites-enabled/exhibitcolumbus.mikeheavers.com-le-ssl.conf:2)
         port 443 namevhost exhibitcolumbus.mikeheavers.com (/etc/apache2/sites-enabled/exhibitcolumbus.mikeheavers.com-le-ssl.conf:2)
                 alias www.exhibitcolumbus.mikeheavers.com
         port 443 namevhost mikeheavers.com (/etc/apache2/sites-enabled/mikeheavers.com-le-ssl.conf:2)
         port 443 namevhost prototypes.mikeheavers.com (/etc/apache2/sites-enabled/prototypes.mikeheavers.com-le-ssl.conf:2)
*:80                   is a NameVirtualHost
         default server 127.0.1.1 (/etc/apache2/sites-enabled/000-default.conf:1)
         port 80 namevhost 127.0.1.1 (/etc/apache2/sites-enabled/000-default.conf:1)
         port 80 namevhost exhibitcolumbus.mikeheavers.com (/etc/apache2/sites-enabled/exhibitcolumbus.mikeheavers.com.conf:1)
                 alias www.exhibitcolumbus.mikeheavers.com
         port 80 namevhost mosaic.mikeheavers.com (/etc/apache2/sites-enabled/mosaic.mikeheavers.com.conf:1)
         port 80 namevhost prototypes.mikeheavers.com (/etc/apache2/sites-enabled/prototypes.mikeheavers.com.conf:1)
         port 80 namevhost selingo.mikeheavers.com (/etc/apache2/sites-enabled/selingo.mikeheavers.com.conf:1)
                 alias www.selingo.mikeheavers.com
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www"
Main ErrorLog: "/var/log/apache2/error.log"

How do I untangle whatever mess I made?

mheavers
  • 127
  • 7

1 Answers1

0

You haven't created a virtual host to serve https://selingo.mikeheavers.com/. Thus when this URL is accessed, Apache chooses the default virtual host, which according to your listing is default server exhibitcolumbus.mikeheavers.com.

You just need to create a new virtual host to serve this site.

Michael Hampton
  • 244,070
  • 43
  • 506
  • 972
  • I did create a vhost - or at least I think I did: I made a copy of my 000-default.conf called selingo.mikeheavers.com.conf, I added the contents (shown above), I did an `a2ensite` for the conf file, and I created an A record in Digital Ocean. That's all I normally do. – mheavers Aug 07 '20 at 23:55
  • @mheavers You have one that serves http on port 80. You don't have one that serves https on port 443. – Michael Hampton Aug 07 '20 at 23:56
  • I guess I'm confused how I would set one up for that port, or why it is even looking at :443 – mheavers Aug 08 '20 at 00:04
  • @mheavers Because you redirected everything to https. And you can set it up like all the others you already set up. – Michael Hampton Aug 08 '20 at 00:05
  • Agh! Thank you...Just needed to run letsencrypt again. – mheavers Aug 08 '20 at 00:13