0

I have both local.domain.com and lmarket.local.domain.com pointing to my localhost from etc/hosts.

The problem is that I am using XAMPP on Windows 7, and have 2 SSL VirtualHosts in my apache config, but no matter which one I access, I am taken to local.domain.com. On non-HTTPS requests all works fine, and the vhosts are basically the same.

Here is the relevant part of my vhosts:

<VirtualHost local.domain.com:443>
    DocumentRoot "C:/xampp/htdocs/local"
    ServerName local.domain.com
    ServerAdmin webmaster@localhost
    ErrorLog "logs/error.log"
    <IfModule log_config_module>
        CustomLog "logs/access.log" combined
    </IfModule>
    SSLEngine on
    SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
    SSLCertificateFile "conf/ssl.crt/server.crt"
    SSLCertificateKeyFile "conf/ssl.key/server.key"
    <FilesMatch "\.(cgi|shtml|pl|asp|php)$">
        SSLOptions +StdEnvVars
    </FilesMatch>
    <Directory "C:/xampp/cgi-bin">
        SSLOptions +StdEnvVars
    </Directory>
    BrowserMatch ".*MSIE.*" nokeepalive ssl-unclean-shutdown downgrade-1.0 force-response-1.0
    CustomLog "logs/ssl_request.log" "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
</VirtualHost>

<VirtualHost lmarket.local.domain.com:443>
    DocumentRoot "C:/xampp/htdocs/lmarket.local"
    ServerName lmarket.local.domain.com
    ServerAdmin webmaster@localhost
    ErrorLog "logs/error.log"
    <IfModule log_config_module>
        CustomLog "logs/access.log" combined
    </IfModule>
    SSLEngine on
    SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
    SSLCertificateFile "conf/ssl.crt/server.crt"
    SSLCertificateKeyFile "conf/ssl.key/server.key"
    <FilesMatch "\.(cgi|shtml|pl|asp|php)$">
        SSLOptions +StdEnvVars
    </FilesMatch>
    <Directory "C:/xampp/cgi-bin">
        SSLOptions +StdEnvVars
    </Directory>
    BrowserMatch ".*MSIE.*" nokeepalive ssl-unclean-shutdown downgrade-1.0 force-response-1.0
    CustomLog "logs/ssl_request.log" "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
</VirtualHost>

If I invert these blocks, then the opposite happens: local.domain.com goes to lmarket.local.domain.com. Any help would be appreciated.

Eduard Luca
  • 371
  • 2
  • 9
  • 19

2 Answers2

1

You probably forgot to tell apache that 127.0.0.1:443 is to be used for name based virtual hosts.

NameVirtualHost 127.0.0.1:443

Or even better

NameVirtualHost *:443

Should be added to your config before the VirtualHost sections. You must also update the VirtualHost with the address that you put for NameVirtualHost. E.g. <VirtualHost *:443>.

chutz
  • 7,888
  • 1
  • 29
  • 59
  • Sorry, forgot to add that part to the code. I do have `NameVirtualHost *:443` at the top of the file, right after `NameVirtualHost *:80` – Eduard Luca Oct 26 '12 at 00:38
  • I updated my answer to emphasize that what I said is a "good idea" is actually very, very important :) – chutz Oct 26 '12 at 02:25
0

Duh, I found the answer... not sure why this is like this, but I've had to change:

<VirtualHost lmarket.local.domain.com:443>

to

<VirtualHost *:443>

and the same for the 2nd vhost. Hope it helps somebody.

Eduard Luca
  • 371
  • 2
  • 9
  • 19