I have a VPS with ubuntu 16, apache and the following three domains:

domain1.com domain2.com

domain1 has SSL enabled. domain2 has no SSL. This is working fine. Now, I tried to create a new site using a subdomain of domain2:


Whenever I try to open that site, the browser will show me a SSL error saying that my SSL certificate is not for that domain. But I don't want SSL on that domain/subdomain !

My domain2.com.conf is identical with my portal.domain2.com.conf file, except for the ServerName and ServerAlias.

What could I be doing wrong?

domain1 configuration:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/domain2.com/public_html
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    ServerName domain2.com
    ServerAlias www.domain2.com

portal.domain1 configuration:

<VirtualHost *:80>
    ServerAdmin email@email.com
    ServerName portal.domain2.com
    DocumentRoot /var/www/portal.domain2.com/public_html

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

Edit 1: If I run apachectl -tD DUMP_VHOSTS:

VirtualHost configuration:
*:443                  domain1.com (/etc/apache2/sites-enabled/domain1.com-le-ssl.conf:2)
*:80                   is a NameVirtualHost
     default server (/etc/apache2/sites-enabled/000-default.conf:1)
     port 80 namevhost (/etc/apache2/sites-enabled/000-default.conf:1)
     port 80 namevhost domain2.com (/etc/apache2/sites-enabled/domain2.conf:1)
             alias www.domain2.com
     port 80 namevhost domain1.com (/etc/apache2/sites-enabled/domain1.com.conf:1)
             alias www.domain1.com
     port 80 namevhost portal.domain2.com (/etc/apache2/sites-enabled/portal.domain2.com.conf:1)
  • You could be doing wrong your configuration, which you haven't provided, though. – Esa Jokinen May 3 '17 at 19:11
  • @EsaJokinen I edited my question with both configurations of domain 2 – Perroloco May 3 '17 at 19:29
  • (1) You restarted apache after changing the config right? (2) what does apachectl -tD DUMP_VHOSTS show? – dave_thompson_085 May 3 '17 at 20:21
  • @dave_thompson_085 I edited the question. Thanks – Perroloco May 3 '17 at 20:32
  • 1
    @Perroloco good god no, not unless you know what it does and what the implications are. If you had sent that header in the past, it would explain the unexpected redirection, that's all – Mark Henderson May 3 '17 at 20:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.