1

I am having problems setting up SSL in Virtual Hosts. The setup works great on unsecure sites. And I want it to work with SSLEnabled sites.

My httpd-vhosts.conf is below:

NameVirtualHost 127.0.0.1
<IfModule mod_rewrite.c>
    RewriteEngine On

    # Redirect /binDebug folder to https
    RewriteCond %{HTTPS} !=on
    RewriteCond %{REQUEST_URI} binDebug
    RewriteRule ^(.*) https://%{SERVER_NAME}$1 [R,L]
</IfModule>

        <VirtualHost localhost>
            ServerName localhost
            DocumentRoot "C:\xampp\htdocs"
            DirectoryIndex index.php index.html

            <Directory "C:\xampp\htdocs">            
                AllowOverride All
            </Directory>
        </VirtualHost>


        <VirtualHost virtual.c7beta.com>
            ServerName virtual.c7beta.com
            DocumentRoot "C:\Users\zee\Documents\Flex Builder 3\CLOUD\bin-debug"
            DirectoryIndex index.php index.html
             Alias /binDebug "C:\Users\zee\Documents\Flex Builder 3\CLOUD\bin-debug/"
            <Directory "C:\Users\zee\Documents\Flex Builder 3\CLOUD\bin-debug">
                Options Indexes FollowSymLinks Includes ExecCGI
                AllowOverride All
                Order allow,deny
                Allow from all
    #   SSLRequireSSL

            </Directory>
        </VirtualHost>

        <VirtualHost virtual.app.c7beta.com>
            ServerName virtual.app.c7beta.com
            DocumentRoot "C:\development\app_server\httpdocs"
            DirectoryIndex index.php index.html

            <Directory "C:\development\app_server\httpdocs">
                Options Indexes FollowSymLinks Includes ExecCGI
                AllowOverride All
                Order allow,deny
                Allow from all
    #   SSLRequireSSL

            </Directory>
        </VirtualHost>

        <VirtualHost virtual.s1.c7beta.com>
            ServerName virtual.s1.c7beta.com
            DocumentRoot "C:\development\storage_server\httpdocs"
            DirectoryIndex index.php index.html

            <Directory "C:\development\storage_server\httpdocs">
                Options Indexes FollowSymLinks Includes ExecCGI
                AllowOverride All
                Order allow,deny
                Allow from all
    #   SSLRequireSSL

            </Directory>
        </VirtualHost>

Right now the SSLRequiesSSL is commented. Can some one check this and tell me what changes should I make to use https, just the way http was working.

I did the configuration changes as suggested by: http://robsnotebook.com/xampp-ssl-encrypt-passwords and it seems like working fine. But still when I type in with my servername.com it redirects to servername.com/xampp

Please help Zeeshan

womble
  • 96,255
  • 29
  • 175
  • 230

2 Answers2

2

The SSL certificate is presented to the browser during SSL negotiation, which happens before the HTTP protocol layer starts up and the Host: header is sent to the server, stating which site is wanted.

You have two options:

  1. Use a certificate valid for multiple hosts, via subjectAltName aliases (or a wildcard glob)
  2. Use TLS ServerNameIndication to also send the desired server hostname during SSL/TLS setup

1 is easy, if you can deal with a CA to get such a certificate issued. 2 requires that both client and server support TLS, that the client support SNI (which means a very modern browser) and that the server support it, which for Apache means that patches are needed. See https://sni.velox.ch/ for patches.

Phil P
  • 3,080
  • 1
  • 16
  • 19
1

Make sure you put port numbers after the VirtualHost foo.bar line ie..

<VirtualHost Virtual.app.c7beta.com:443>
...
</VirtualHost>

<VirtualHost Virtual1.app.c7beta.com:80>
....
</VirtualHost>

This is per the apache configuration documentation for setting up virtual SSL servers.

womble
  • 96,255
  • 29
  • 175
  • 230
Stephen Thompson
  • 1,482
  • 9
  • 10