Vhost resolving wrong certificate

@rucaza Excellent. Thanks

I think the issue is you have:

<VirtualHost psyc.bbk.ac.uk:443>
<VirtualHost unlocke.org:443>

But, for briccentre just:

<VirtualHost *:443>

Note no fully qualified domain name and instead just a wildcard. The FQDN just represents the related IP address.

I think you can resolve this by making all of them *:443 instead of using the FQDN for psyc and unlocke.

Per Apache docs:

When a request is received, the server first maps it to the best matching based on the local IP address and port combination only. Non-wildcards have a higher precedence. If no match based on IP and port occurs at all, the "main" server configuration is used.

So, what is happening is a request for briccentre arrives. Apache sees that both pysc and unlocke match the IP address. Then it matches the host header on the request but finds no matching name in these two so uses the default (psyc) server.

In other words, the use of the FQDN limits the candidates of which servers will be selected.

There is a time and place for IP based selection but yours does not seem like it.
All of the domains resolve to the same IP. Note, also, this "not recommended" notation in the VirtualHost definition:

A fully qualified domain name for the IP address of the virtual host (not recommended);
core - Apache HTTP Server Version 2.4

Also, just for consistency I noticed you use different IfModule but these are normally the same so is probably not a problem. I generally prefer consistency so if you are setting up a pattern you may want to standardize on one.

For briccentre you wrap the VirtualHost with:
<IfModule mod_ssl.c>
For the other ssl VirtualHost you use:
<IfModule ssl_module>

I am curious to know how this turns out. Cheers

2 Likes