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.

I have an issue with Aliases on Apache on Ubuntu 10.04.3

What I am trying to do is as follows :-

  • One subdomain (mydomain.domain.com) on port 80 - that redirects to port 443 of mydomain.domain.com
  • One subdomain (mydomain.domain.com) on port 443 with SSlEngine on

  • Wildcard subdomains (*.domain.com) on port 80 - that redirects to port 443 of *.domain.com:443

  • Wildcard subdomains (*.domain.com) on port 443 with SSlEngine on

I've got one file in /etc/apache2/sites-available folder

<VirtualHost *:80>
    ServerName mydomain.domain.com
    DocumentRoot /var/www/mydomain
    DirectoryIndex index.cfm

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
</VirtualHost>

<VirtualHost *:443>
    ServerName mydomain.domain.com:443
    DocumentRoot /var/www/mydomain
    DirectoryIndex index.cfm

RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
RewriteRule ^([a-zA-Z0-9/_/-]+)$ /index.cfm%{REQUEST_URI} [PT]


SSLEngine on
SSLProtocol -all +SSLv3 +TLSv1
...
...
</VirtualHost>

<VirtualHost *:80>
    ServerName something.domain.com
    ServerAlias *.domain.com
    DocumentRoot /var/www/mydomain_all
    DirectoryIndex index.cfm

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
</VirtualHost>

<VirtualHost *:443>
    ServerName something.domain.com:443
    ServerAlias *.domain.com:443
    DocumentRoot /var/www/mydomain_all
    DirectoryIndex index.cfm

RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
RewriteRule ^([a-zA-Z0-9/_/-]+)$ /index.cfm%{REQUEST_URI} [PT]


SSLEngine on
SSLProtocol -all +SSLv3 +TLSv1
...
...
</VirtualHost>

The problem is that all requests to anything.domain.com actually go to the first ssl VH ie mydomain.domain.com - have I got the order wrong? or something else wrong?

share|improve this question

1 Answer 1

up vote 0 down vote accepted

You'll need a NameVirtualHost *:443 directive for vhosts other than the first one on the port to function.

Depending on your Apache and OpenSSL versions, it may throw a warning during startup about multiple vhosts on an SSL port - feel free to ignore it.

Are you using the same certificate (hopefully a wildcard) for the two SSL vhosts, or different ones? If they're different, then connecting clients that do not support SNI will always get the certificate for the first vhost.

share|improve this answer
    
NameVirtualHost *:80 NameVirtualHost *:443 Listen 80 <IfModule mod_ssl.c> # If you add NameVirtualHost *:443 here, you will also have to change # the VirtualHost statement in /etc/apache2/sites-available/default-ssl # to <VirtualHost *:443> # Server Name Indication for SSL named virtual hosts is currently not # supported by MSIE on Windows XP. Listen 443 https </IfModule> <IfModule mod_gnutls.c> Listen 443 https </IfModule> –  Jimmy Oct 27 '11 at 14:46
    
The above is how my ports.conf looks like and It's the same Wildcard SSL cert on all subdomains. @ShaneMadden –  Jimmy Oct 27 '11 at 14:47
    
@Jimmy Does Apache put any warnings or errors in the error log during startup? –  Shane Madden Oct 27 '11 at 15:08
    
No it does not. Also, the Apache version is 2.2.14 –  Jimmy Oct 27 '11 at 15:14
    
@Jimmy Well, if it's not warning about an issue with the host header mapping, or erroring with an issue on the SSL certificate or something, then it should be working just fine. Are you absolutely sure the requests are being served by the wrong vhost? They are both being sent to a copy of an index.cfm... –  Shane Madden Oct 27 '11 at 15:20

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.