0

Possible Duplicate:
Last (I think and hope) problems configuring SSL certificate with Apache and VirtualHosts

Finally I set apache2 to get a single certificate for all subdomains.

[...]

# Go ahead and accept connections for these vhosts
# from non-SNI clients
SSLStrictSNIVHostCheck off


# Apache setup which will listen for and accept SSL connections on port 443.
Listen 443
# Listen for virtual host requests on all IP addresses
NameVirtualHost *:443


# Because this virtual host is defined first, it will
# be used as the default if the hostname is not received
# in the SSL handshake, e.g. if the browser doesn't support
# SNI.
<VirtualHost *:443>
  ServerName domain.localhost
  DocumentRoot "/Users/<my_user_name>/Sites/domain/public"

  <Directory "/Users/<my_user_name>/Sites/domain/public">
    Order allow,deny
    Allow from all
  </Directory>

  # SSL Configuration
  SSLEngine on
  ...
</VirtualHost>


<VirtualHost *:443>
  ServerName subdomain1.domain.localhost
  DocumentRoot "/Users/<my_user_name>/Sites/subdomain1/public"

  <Directory "/Users/<my_user_name>/Sites/subdomain1/public">
    Order allow,deny
    Allow from all
  </Directory>

  # SSL Configuration
  SSLEngine on
  ...
</VirtualHost>


<VirtualHost *:443>
  ServerName subdomain2.domain.localhost
  DocumentRoot "/Users/<my_user_name>/Sites/subdomain2/public"

  <Directory "/Users/<my_user_name>/Sites/subdomain2/public">
    Order allow,deny
    Allow from all
  </Directory>

  # SSL Configuration
  SSLEngine on
  ...
</VirtualHost>

So, for example, I can correctly access

https://subdomain1.domain.localhost
https://subdomain2.domain.localhost
...

Now, anyway, I have problems on accessing

http://subdomain1.domain.localhost
http://subdomain2.domain.localhost
...

Since I use a Mac Os, on accessing the "http: version", I get a default page "Your website." (instead of a error). Why does it happen?

0

1 Answer 1

0

For the http://foo you'll need other virtualhosts starting with

<VirtualHost *:80>

Do you have them?

http://www.foo.com and https://www.foo.com are distinct Virtualhosts.

You need as well to listen not only on port 443, check you have a Listen 80 as well and the NameVirtualHost *:80. Well if you have the 'It works' chances are that you have theses settings but not the Virtualhosts.

You can ask apache for a complete listing of what he understand of your Virtualhosts. here I use 'apache2', depending on your installation the apache binary could be 'httpd' or something else. execute :

apache 2 -S

or

apache2 -t -D DUMP_VHOSTS 

Then you'll get the list of virtualhosts. You can see virtualhosts on *:80and *:443 are on different stacks.

If you think it's boring to copy-paste long Virtualhosts definitions which are quite the same on the *:80 and the *:443 Virtualhosts use Include instruction to share the settings which are the same between the VHs.

4
  • 'apache 2 -S' and 'apache2 -t -D DUMP_VHOSTS' don't work on my Mac OS.
    – user65567
    Jan 6, 2011 at 23:56
  • 1
    I can't edit your answer, but if you had something like <VirtualHost *:80>, you can use \< to keep the tag from being eaten by SO's HTML parser. Jan 7, 2011 at 2:39
  • @SilverbackNet yes, thanks, I was tired, I forgot to check the escapes.
    – regilero
    Jan 7, 2011 at 7:22
  • @user502052 did you try with httpd instead of apache2 ?
    – regilero
    Jan 7, 2011 at 7:23

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