0

I am setting up multiple subdomains/domains with different ssl certificates on one server and I have a problem. Namely, VirtualHost *:443 is being ignored and first VirtualHost is being loaded.

My initial setup was like this:

 <VirtualHost *:443>
    ServerName a1.domain.com
    ....
    SSLCertificateFile    /etc/ssl/domain.crt
    ....
 </VirtualHost>
 <VirtualHost *:443>
    ServerName a2.domain.com
    ....
    SSLCertificateFile    /etc/ssl/domain.crt
    ....
 </VirtualHost>

But then when I added a standalonde domain like this

 <VirtualHost *:443>
    ServerName new-domain.com
    ....
    SSLCertificateFile    /etc/ssl/new-domain.crt
    ....
 </VirtualHost>

It all went to hell. Every previous domain was trying to get a certificate file new-domain.crt... why I have no idea... So then I thought ok, lets fix it and I changed all VirtualHosts to this:

 <VirtualHost a1.domain.com:443>
    ServerName a1.domain.com
    ....
    SSLCertificateFile    /etc/ssl/domain.crt
    ....
 </VirtualHost>
 <VirtualHost a2.domain.com:443>
    ServerName a2.domain.com
    ....
    SSLCertificateFile    /etc/ssl/domain.crt
    ....
 </VirtualHost>
 <VirtualHost new-domain.com:443>
    ServerName new-domain.com
    ....
    SSLCertificateFile    /etc/ssl/new-domain.crt
    ....
 </VirtualHost>

And certificates started to work... however I also have an entry like this:

 <VirtualHost _default_:443>
     ServerName root-domain.com
     ...
     # here it points to default landing page
 </VirtualHost>

Before I made changes all default trafic to nonexistent axxx.domain.com (of if I just use IP) was comming to the default but now it ends up in a1.domain.com (its listed as first if I use apache2ctl -S).

I think my initial setup was a case of misconfiguration and it worked like I wanted 'by accident' but I am not sure how to make it work now...

P.S. VirtualHostName is deprectaed so I cant use that...

1 Answer 1

0

where is the server alias for each virtual domains?

it is obvious that apache will serve the first domain if you never tell apache how many different domains are configured.

you can tell this in one way only, aliasing:

ServerAlias example.com

Furthermore, you don't need to declare the domain name in:

 <VirtualHost a1.domain.com:443>

This will work enough:

 <VirtualHost *:443>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .