69

I have two ruby on rails 3 applications running on same server, (ubuntu 10.04), both with SSL.

Here is my apache config file:

<VirtualHost *:80>
ServerName example1.com
DocumentRoot /home/me/example1/production/current/public
</VirtualHost>
<VirtualHost *:443>
ServerName example1.com
DocumentRoot /home/me/example1/production/current/public
SSLEngine on
SSLCertificateFile /home/me/example1/production/shared/example1.crt
SSLCertificateKeyFile /home/me/example1/production/shared/example1.key
SSLCertificateChainFile /home/me/example1/production/shared/gd_bundle.crt
SSLProtocol -all +TLSv1 +SSLv3
SSLCipherSuite HIGH:MEDIUM:!aNULL:+SHA1:+MD5:+HIGH:+MEDIUM
</VirtualHost>


<VirtualHost *:80>
ServerName example2.com
DocumentRoot /home/me/example2/production/current/public
</VirtualHost>
<VirtualHost *:443>
ServerName example2.com
DocumentRoot /home/me/example2/production/current/public
SSLEngine on
SSLCertificateFile /home/me/example2/production/shared/iwanto.crt
SSLCertificateKeyFile /home/me/example2/production/shared/iwanto.key
SSLCertificateChainFile /home/me/example2/production/shared/gd_bundle.crt
SSLProtocol -all +TLSv1 +SSLv3
SSLCipherSuite HIGH:MEDIUM:!aNULL:+SHA1:+MD5:+HIGH:+MEDIUM
</VirtualHost>

Whats the issue:

On restarting my server it gives me some output like this:

 * Restarting web server apache2                                   
 [Sun Jun 17 17:57:49 2012] [warn] _default_ VirtualHost overlap on port 443, the first has precedence
 ... waiting [Sun Jun 17 17:57:50 2012] [warn] _default_ VirtualHost overlap on port 443, the first has precedence

On googling why this issue is coming I got something like this:

You cannot use name based virtual hosts with SSL because the SSL handshake (when the browser accepts the secure Web server's certificate) occurs before the HTTP request, which identifies the appropriate name based virtual host. If you plan to use name-based virtual hosts, remember that they only work with your non-secure Web server.

But not able to figure out how to run two ssl application on same server.

Can any one help me?

1
  • 5
    You don't have any _default_ vhosts in the config you've provided, so they're elsewhere. What's the output of apache2ctl -S? (Yes, it is possible to run multiple SSL name-based vhosts on different certificates, provided you don't have any need to support client browsers running Windows XP or any others that don't support TLS SNI. Do you need to support Windows XP?) Jun 17, 2012 at 22:48

4 Answers 4

92

Almost there!

Add this to ports.conf or http.conf and keep your above config.

<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.

    # !important below!
    NameVirtualHost *:443 
    Listen 443
</IfModule>
3
  • The comment "# !important! needs to be removed or moved to another line. Otherwise, thank you very much for interpreting this inaccurate error message for me.
    – flickerfly
    Sep 10, 2014 at 19:03
  • 3
    This no longer works in Apache 2.4.7
    – malhal
    Oct 3, 2014 at 19:25
  • Thank you. I found I needed to comment out Listen 443 because that's also being used in my individual conf.d/website.conf configs
    – dlink
    Jun 14, 2018 at 21:02
4

It helped me executing " /usr/sbin/apachectl -S" also. This command exit shows TWO "ssl.conf" files on the same path. Move or delete the offender file and everything should work after.

1

You can add this to your apache config at /etc/apache2/ports.conf:

<IfModule mod_ssl.c>                
    Listen 443                      
    <IfModule !mod_authz_core.c>    
        # Apache 2.2                
        NameVirtualHost *:443       
    </IfModule>                     
</IfModule>                         

(This works in both: apache 2.2 and 2.4)

0

Just find where the "Listen 443" is and paste above NameVirtualHost *:443 In my case was in ssl.conf file

If you restart the http server and you are getting the message "Listen 443 is deprecated" delete "Listen 443" and leave only NameVirtualHost *:443

1
  • 2
    Warning: NameVirtualHost is deprecated and has no effect in current versions of Apache. It may be helpful for very old versions of Apache though. Sep 28, 2020 at 12:37

You must log in to answer this question.

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