Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

migrated from stackoverflow.com Jan 10 '11 at 12:05

This question came from our site for professional and enthusiast programmers.

marked as duplicate by MikeyB, mulaz, Ward, Magellan, Iain Oct 17 '12 at 21:16

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

add comment

1 Answer

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.

share|improve this answer
    
'apache 2 -S' and 'apache2 -t -D DUMP_VHOSTS' don't work on my Mac OS. –  user65567 Jan 6 '11 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. –  SilverbackNet Jan 7 '11 at 2:39
    
@SilverbackNet yes, thanks, I was tired, I forgot to check the escapes. –  regilero Jan 7 '11 at 7:22
    
@user502052 did you try with httpd instead of apache2 ? –  regilero Jan 7 '11 at 7:23
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.