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

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?

EDIT: Partially solved B-\

Add "somewhere" in the 'httpd.conf' this code for all subdomains a for the domain (example for 'domain.localhost'):

<VirtualHost *:80>
  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>
</VirtualHost>

Now when I try to access http://subdomain1.domain.localhost or http://subdomain2.domain.localhost, the browser redirect me automatically to http://domain.localhost. Why? How solve it?

share|improve this question
    
Do you have any virtualhosts defined for VirtualHost *:80 –  Zoredache Jan 6 '11 at 1:05
    
No yet! I am trying. If you have some help... –  user65567 Jan 6 '11 at 4:01

2 Answers 2

up vote 0 down vote accepted

Now add the part from your EDIT <VirtualHost *:80> for each subdomain:

<VirtualHost *:80>
   ServerName subdomain1.domain.localhost
...

<VirtualHost *:80>
   ServerName subdomain2.domain.localhost
...
share|improve this answer
    
I added these for all subdomains and for the domain, but now when I access http: //subdomain1.domain.localhost or http: //subdomain2.domain.localhost, the browser redirect me automatically to http: //domain.localhost. Why? How resolve it? –  user65567 Jan 6 '11 at 14:41
    
The trick is to add 'NameVirtualHost *: 80'! SOLVED. –  user65567 Jan 6 '11 at 15:40

You must have a separate definition for all the http virtualhosts. So, for each https, a matching http.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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